Retrieves a list of customer summary objects that match the specified criteria.
Parameter |
Type |
Description |
---|---|---|
criteria |
The customer criteria object that specifies which customer summary objects are returned. |
|
context |
Specifies information about how the method will be called. |
Value |
Type |
Description |
---|---|---|
GetCustomerListResult |
The list of customer summary objects that match the specified criteria. |
The following C# example retrieves the list of customer summary objects for the customers whose State property is “ND”. The total number of customers 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; CustomerCriteria customerCriteria; CustomerSummary[] customerSummaryList; LikeRestrictionOfString stateRestriction; // Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); // Be sure that default credentials are being 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 context.OrganizationKey = (OrganizationKey)companyKey; // Specify the criteria for the customer summaries to retrieve stateRestriction = new LikeRestrictionOfString(); stateRestriction.Like = "%ND%"; customerCriteria = new CustomerCriteria(); customerCriteria.State = stateRestriction; // Retrieve the list of customer summaries customerSummaryList = wsDynamicsGP.GetCustomerList(customerCriteria, context); // Display the number of customers matching the criteria MessageBox.Show("North Dakota customers: " + customerSummaryList.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; CustomerCriteria customerCriteria; CustomerSummary[] customerSummaryList; 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 context.OrganizationKey = (OrganizationKey)companyKey; // Specify the criteria for the customer summaries to retrieve stateRestriction = new LikeRestrictionOfstring(); stateRestriction.Like = "%ND%"; customerCriteria = new CustomerCriteria(); customerCriteria.State = stateRestriction; // Retrieve the list of customer summaries customerSummaryList = wsDynamicsGP.GetCustomerList(customerCriteria, context); // Display the number of customers matching the criteria MessageBox.Show("North Dakota customers: " + customerSummaryList.Length.ToString()); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }