GetChangedSalespersonKeyList


Description

Retrieves a list of changed salesperson key objects for the salespersons that have been acted on during the specified interval. A salesperson 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

SalespersonChangedKeyCriteria

The salesperson changed key criteria object that specifies which changed salesperson key objects to return.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetChangedSalespersonKeyListResult

ArrayOfChangedSalespersonKey

The list of changed salesperson key objects that match the specified criteria.


Interfaces

 

Examples

The following C# example retrieves the list of the changed salesperson key objects for all of the salespersons that were created during the current day. The data modification action restriction is used so that only create actions are included in the list returned. A message box displays the number of salespersons that were created.

 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;
			SalespersonChangedKeyCriteria salespersonCriteria;
			ChangedSalespersonKey[] changedSalespersonKeyObjects;
			BetweenRestrictionOfNullableOfDateTime restriction;
			RestrictionOfDataModificationAction dataModificationRestriction;

			// 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 restriction so only created salespeople are returned
			dataModificationRestriction = new RestrictionOfDataModificationAction();
			dataModificationRestriction.EqualValue = DataModificationAction.Created;

			// Create the criteria to return salesperson objects that were created
			salespersonCriteria = new SalespersonChangedKeyCriteria();
			salespersonCriteria.LastModifiedDate = restriction;
			salespersonCriteria.Action = dataModificationRestriction;

			// Retrieve the created salesperson key objects
			changedSalespersonKeyObjects = wsDynamicsGP.GetChangedSalespersonKeyList(salespersonCriteria, context);

			// Display the number of salesperson objects that were created today
			MessageBox.Show("Created salesperson objects: " + changedSalespersonKeyObjects.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;
			SalespersonChangedKeyCriteria salespersonCriteria;
			ChangedSalespersonKey[] changedSalespersonKeyObjects;
			BetweenRestrictionOfNullableOfdateTime restriction;
			RestrictionOfDataModificationAction dataModificationRestriction;

			// 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 restriction so only created salespeople are returned
			dataModificationRestriction = new RestrictionOfDataModificationAction();
			dataModificationRestriction.EqualValue = DataModificationAction.Created;

			// Create the criteria to return salesperson objects that were created
			salespersonCriteria = new SalespersonChangedKeyCriteria();
			salespersonCriteria.LastModifiedDate = restriction;
			salespersonCriteria.Action = dataModificationRestriction;

			// Retrieve the created salesperson key objects
			changedSalespersonKeyObjects = wsDynamicsGP.GetChangedSalespersonKeyList(salespersonCriteria, context);

			// Display the number of salesperson objects that were created today
			MessageBox.Show("Created salesperson objects: " + changedSalespersonKeyObjects.Length.ToString());

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


Documentation Feedback