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

 

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.

 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);
	}
}
}

 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)
		{
			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();
		}
	}
}
}


Documentation Feedback