GetChangedCustomerKeyList
Description
Retrieves a list of changed customer key objects for the customers that have been acted on during the specified interval. A customer has been acted on if it has been created, updated, or deleted. Entity change tracking must be enabled for this method to return valid results.
Parameters
Parameter |
Type |
Description |
---|---|---|
criteria |
The customer changed key criteria object that specifies which changed customer key objects to return. |
|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
---|---|---|
GetChangedCustomerKeyListResult |
The list of changed customer key objects that match the specified criteria. |
Interfaces
- Dynamics GP
Examples
The following C# example retrieves the list of the changed customer key objects for all of the customers that have been acted on during the current day. Because no additional restriction was added, all of the create, update, and delete actions are included. A message box displays the number of customers that were acted on.
** 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; CustomerChangedKeyCriteria customerCriteria; ChangedCustomerKey[] changedCustomerKeyObjects; BetweenRestrictionOfNullableOfDateTime restriction; // 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 the restriction that defines the interval examined for changes // The following restriction includes all of today restriction = new BetweenRestrictionOfNullableOfDateTime(); restriction.From = DateTime.Today.Date; restriction.To = DateTime.Today.Date.AddDays(1); // Create the criteria to return changed customer objects customerCriteria = new CustomerChangedKeyCriteria(); customerCriteria.LastModifiedDate = restriction; // Retrieve the changed customer key objects changedCustomerKeyObjects = wsDynamicsGP.GetChangedCustomerKeyList(customerCriteria, context); // Display the number of customer objects that changed MessageBox.Show("Changed customer objects: " + changedCustomerKeyObjects.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; CustomerChangedKeyCriteria customerCriteria; ChangedCustomerKey[] changedCustomerKeyObjects; BetweenRestrictionOfNullableOfdateTime restriction; // 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 the restriction that defines the interval examined for changes // The following restriction includes all of today restriction = new BetweenRestrictionOfNullableOfdateTime(); restriction.From = DateTime.Today.Date; restriction.To = DateTime.Today.Date.AddDays(1); // Create the criteria to return changed customer objects customerCriteria = new CustomerChangedKeyCriteria(); customerCriteria.LastModifiedDate = restriction; // Retrieve the changed customer key objects changedCustomerKeyObjects = wsDynamicsGP.GetChangedCustomerKeyList(customerCriteria, context); // Display the number of customer objects that changed MessageBox.Show("Changed customer objects: " + changedCustomerKeyObjects.Length.ToString()); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }