GetCustomerAddressList
Description
Retrieves a list of customer address summary objects that match the specified criteria.
Parameters
Parameter |
Type |
Description |
---|---|---|
criteria |
The customer address criteria object that specifies which customer address summary objects are returned. |
|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
---|---|---|
GetCustomerAddressListResult |
The list of customer address summary objects that match the specified criteria. |
Interfaces
- Dynamics GP
- Sales
Examples
The following C# example retrieves the list of customer address summary objects where the customer has a primary address in the state "IL". The total number of customer 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; CustomerAddressSummary[] customerAddressList; CustomerAddressCriteria customerAddressCriteria; LikeRestrictionOfString addressRestriction; LikeRestrictionOfString stateRestriction; // 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; // Create a customer address criteria object addressRestriction = new LikeRestrictionOfString(); addressRestriction.Like = "PRIMARY"; stateRestriction = new LikeRestrictionOfString(); stateRestriction.EqualValue = "IL"; customerAddressCriteria = new CustomerAddressCriteria(); customerAddressCriteria.CustomerAddressKeyId = addressRestriction; customerAddressCriteria.State = stateRestriction; // Retrieve the customer address summary objects customerAddressList = wsDynamicsGP.GetCustomerAddressList(customerAddressCriteria, context); // Display the number of customers that have a primary address in the specified state MessageBox.Show("Total number of customers with a primary address in IL: " + customerAddressList.Length.ToString()); } } }
** Native endpoint **
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.Windows.Forms; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; CustomerAddressSummary[] customerAddressList; CustomerAddressCriteria customerAddressCriteria; LikeRestrictionOfstring addressRestriction; LikeRestrictionOfstring stateRestriction; // 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; // Create a customer address criteria object addressRestriction = new LikeRestrictionOfstring(); addressRestriction.Like = "PRIMARY"; stateRestriction = new LikeRestrictionOfstring(); stateRestriction.EqualValue = "IL"; customerAddressCriteria = new CustomerAddressCriteria(); customerAddressCriteria.CustomerAddressKeyId = addressRestriction; customerAddressCriteria.State = stateRestriction; // Retrieve the customer address summary objects customerAddressList = wsDynamicsGP.GetCustomerAddressList(customerAddressCriteria, context); // Display the number of customers that have a primary address in the specified state MessageBox.Show("Total number of customers with a primary address in IL: " + customerAddressList.Length.ToString()); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }