GetBusinessObjectUserAssignmentList


Description

Retrieves a list of all the business object user assignment objects. Each business object user assignment represents a Windows User ID that is mapped to an ID in Microsoft Dynamics GP.

Parameters

Parameter

Type

Description

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetBusinessObjectUserAssignmentListResult

ArrayOfBusinessObjectUserAssignment

A list of business object user assignment objects.


Interfaces

 

Examples

The following C# example retrieves all of the business object user assignments and displays the details of each in a message box.

 Legacy endpoint

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			Context context;
			string objectTypeName;
			Company company;
			UserAssignableBusinessObject[] userAssignableBusinessObjects;
			BusinessObjectUserAssignment[] businessObjectUserAssignments;

			// Create an instance of the service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure the default credentials are used
			wsDynamicsGP.UseDefaultCredentials = true;

			// Create a context with which to call the service
			context = new Context();

			// Set up the context object
			context.OrganizationKey = null;

			// Retrieve the list of user-assignable business objects
			userAssignableBusinessObjects = wsDynamicsGP.GetUserAssignableBusinessObjectList(context);

			// Retrieve the business object user assignment objects
			businessObjectUserAssignments = wsDynamicsGP.GetBusinessObjectUserAssignmentList(context);

			// Display the business object user assignments in the list
			StringBuilder assignmentList = new StringBuilder();
			foreach (BusinessObjectUserAssignment a in businessObjectUserAssignments)
			{
				// Look up the object type
				objectTypeName = "";
				foreach (UserAssignableBusinessObject u in userAssignableBusinessObjects)
				{
					if (a.BusinessObjectTypeId == u.BusinessObjectTypeId)
					{
						objectTypeName = u.BusinessObjectTypeDisplayName;
				}
			}

				// Look up the company
				company = wsDynamicsGP.GetCompanyByKey((CompanyKey)a.OrganizationKey, context);

				// Build the string to display
				assignmentList.AppendLine("Windows user: " + a.User + "  Object type:" + objectTypeName +
				"  ID:" + a.BusinessObjectKey + "  Company:" + company.Name);
		}
			MessageBox.Show(assignmentList.ToString());
	}
}
}

 Native endpoint

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			Context context;
			string objectTypeName;
			Company company;
			UserAssignableBusinessObject[] userAssignableBusinessObjects;
			BusinessObjectUserAssignment[] businessObjectUserAssignments;

			// Create an instance of the service
			DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

			// Create a context with which to call the service
			context = new Context();

			// Set up the context object
			context.OrganizationKey = null;

			// Retrieve the list of user-assignable business objects
			userAssignableBusinessObjects = wsDynamicsGP.GetUserAssignableBusinessObjectList(context);

			// Retrieve the business object user assignment objects
			businessObjectUserAssignments = wsDynamicsGP.GetBusinessObjectUserAssignmentList(context);

			// Display the business object user assignments in the list
			StringBuilder assignmentList = new StringBuilder();
			foreach (BusinessObjectUserAssignment a in businessObjectUserAssignments)
			{
				// Look up the object type
				objectTypeName = "";
				foreach (UserAssignableBusinessObject u in userAssignableBusinessObjects)
				{
					if (a.BusinessObjectTypeId == u.BusinessObjectTypeId)
					{
						objectTypeName = u.BusinessObjectTypeDisplayName;
				}
			}

				// Look up the company
				company = wsDynamicsGP.GetCompanyByKey((CompanyKey)a.OrganizationKey, context);

				// Build the string to display
				assignmentList.AppendLine("Windows user: " + a.User + "  Object type:" + objectTypeName +
				"  ID:" + a.BusinessObjectKey + "  Company:" + company.Name);
		}
			MessageBox.Show(assignmentList.ToString());

			// Close the service
			if(wsDynamicsGP.State != CommunicationState.Faulted)
			{
				wsDynamicsGP.Close();
		}
	}
}
}


Documentation Feedback