Share via


GetCurrencyByKey

Description

Retrieves a single currency object based on the key value supplied.

Parameters

Parameter

Type

Description

key

CurrencyKey

The currency key object that specifies the currency to retrieve.

context

Context

Specifies information about how the method will be called.

Return Value:

Value

Type

Description

GetCurrencyByKeyResult

Currency

A currency object.

Interfaces

  • Dynamics GP
  • Common
  • Field Service
  • Financials
  • Human Resources/Payroll
  • Inventory
  • Manufacturing
  • Project Accounting
  • Purchasing
  • Sales

Examples

The following C# example retrieves the currency with the key value "NZD", representing New Zealand dollars. The description of the currency is displayed in a message box.

Cc508472.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;
            Currency currency;
            CurrencyKey currencyKey;

            // 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();

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

            // Create the key for the currency to retrieve
            currencyKey = new CurrencyKey();
            currencyKey.ISOCode = "NZD";

            // Retrieve the currency object
            currency = wsDynamicsGP.GetCurrencyByKey(currencyKey, context);

            // Display the currency description
            MessageBox.Show(currency.Description);
        }
    }
}

Cc508472.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;
            Currency currency;
            CurrencyKey currencyKey;

            // 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
            context.OrganizationKey = null;

            // Create the key for the currency to retrieve
            currencyKey = new CurrencyKey();
            currencyKey.ISOCode = "NZD";

            // Retrieve the currency object
            currency = wsDynamicsGP.GetCurrencyByKey(currencyKey, context);

            // Display the currency description
            MessageBox.Show(currency.Description);

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