Share via


GetChangedCurrencyKeyList

Description

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

CurrencyChangedKeyCriteria

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

context

Context

Specifies information about how the method will be called.

Return Value:

Value

Type

Description

GetChangedCurrencyKeyListResult

ArrayOfChangedCurrencyKey

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

Interfaces

  • Dynamics GP

Examples

The following C# example retrieves the list of the changed currency key objects that have been acted on during the last week. A message box displays the number of each type of action that was performed.

Dd996486.LegacyEndpoint(en-us,MSDN.10).gif** 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)
        {
            Context context;
            CurrencyChangedKeyCriteria currencyCriteria;
            ChangedCurrencyKey[] changedCurrencyKeyObjects;
            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();

            // Set up the context object
            context.OrganizationKey = null;

            // Create the restriction that defines the interval examined for changes
            // The following restriction includes the last week
            restriction = new BetweenRestrictionOfNullableOfDateTime();
            restriction.From = DateTime.Today.Date.AddDays(-7);
            restriction.To = DateTime.Today.Date.AddDays(1);

            // Create the criteria to return currency objects that changed
            currencyCriteria = new CurrencyChangedKeyCriteria();
            currencyCriteria.LastModifiedDate = restriction;

            // Retrieve the changed currency key objects
            changedCurrencyKeyObjects = wsDynamicsGP.GetChangedCurrencyKeyList(currencyCriteria, context);

            // Display the numbers for currencies that were acted on this week
            int created = 0;
            int updated = 0;
            int deleted = 0;

            foreach (ChangedCurrencyKey key in changedCurrencyKeyObjects)
            {
                if (key.Action == DataModificationAction.Created)
                    created++;

                if (key.Action == DataModificationAction.Updated)
                    updated++;

                if (key.Action == DataModificationAction.Deleted)
                    deleted++;
            }

            string message;
            message = "Currency changes: \n";
            message = message + "Created: " + created.ToString() + "\n";
            message = message + "Updated: " + updated.ToString() + "\n";
            message = message + "Deleted: " + deleted.ToString() + "\n";

            MessageBox.Show(message);
        }
    }
}

Dd996486.NativeEndpoint(en-us,MSDN.10).gif** 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)
        {
            Context context;
            CurrencyChangedKeyCriteria currencyCriteria;
            ChangedCurrencyKey[] changedCurrencyKeyObjects;
            BetweenRestrictionOfNullableOfdateTime restriction;

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

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

            // Set up the context object
            context.OrganizationKey = null;

            // Create the restriction that defines the interval examined for changes
            // The following restriction includes the last week
            restriction = new BetweenRestrictionOfNullableOfdateTime();
            restriction.From = DateTime.Today.Date.AddDays(-7);
            restriction.To = DateTime.Today.Date.AddDays(1);

            // Create the criteria to return currency objects that changed
            currencyCriteria = new CurrencyChangedKeyCriteria();
            currencyCriteria.LastModifiedDate = restriction;

            // Retrieve the changed currency key objects
            changedCurrencyKeyObjects = wsDynamicsGP.GetChangedCurrencyKeyList(currencyCriteria, context);

            // Display the numbers for currencies that were acted on this week
            int created = 0;
            int updated = 0;
            int deleted = 0;

            foreach (ChangedCurrencyKey key in changedCurrencyKeyObjects)
            {
                if (key.Action == DataModificationAction.Created)
                    created++;

                if (key.Action == DataModificationAction.Updated)
                    updated++;

                if (key.Action == DataModificationAction.Deleted)
                    deleted++;
            }

            string message;
            message = "Currency changes: \n";
            message = message + "Created: " + created.ToString() + "\n";
            message = message + "Updated: " + updated.ToString() + "\n";
            message = message + "Deleted: " + deleted.ToString() + "\n";

            MessageBox.Show(message);

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