GetCompanyAddressList


Description

Retrieves a list of company address objects that match the specified criteria.

Parameters

Parameter

Type

Description

criteria

CompanyAddressCriteria

The company address criteria object that specifies which company address objects are returned.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetCompanyAddressListResult

ArrayOfCompanyAddress

The list of company address objects that match the specified criteria.


Interfaces

 

Examples

The following C# example retrieves the list of company address objects for the company specified by the company key object. The restriction object’s Like property is “%” to return all company addresses. The total number of company addresses is displayed 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)
		{
			CompanyKey companyKey;
			Context context;
			CompanyAddress[] companyAddress;
			CompanyAddressCriteria addressCriteria;
			LikeRestrictionOfString addressRestriction;

			// 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();

			// Specify which company to use (sample company)
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

			// Set up the context object
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Use the % wildcard to return all existing addresses
			addressRestriction = new LikeRestrictionOfString();
			addressRestriction.Like = "%";

			// Create a criteria object to specify the records to be retrieved
			addressCriteria = new CompanyAddressCriteria();
			addressCriteria.Id = addressRestriction;

			// Retrieve the list of company address objects
			companyAddress = wsDynamicsGP.GetCompanyAddressList(addressCriteria, context);

			// Display the number of addresses returned
			MessageBox.Show("Number of addresses: " + companyAddress.Length.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)
		{
			CompanyKey companyKey;
			Context context;
			CompanyAddress[] companyAddress;
			CompanyAddressCriteria addressCriteria;
			LikeRestrictionOfstring addressRestriction;

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

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

			// Specify which company to use (sample company)
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

			// Set up the context object
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Use the % wildcard to return all existing addresses
			addressRestriction = new LikeRestrictionOfstring();
			addressRestriction.Like = "%";

			// Create a criteria object to specify the records to be retrieved
			addressCriteria = new CompanyAddressCriteria();
			addressCriteria.Id = addressRestriction;

			// Retrieve the list of company address objects
			companyAddress = wsDynamicsGP.GetCompanyAddressList(addressCriteria, context);

			// Display the number of addresses returned
			MessageBox.Show("Number of addresses: " + companyAddress.Length.ToString());

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


Documentation Feedback