Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Description
Retrieves a single currency object based on the key value supplied.
Parameters
Parameter |
Type |
Description |
|---|---|---|
key |
The currency key object that specifies the currency to retrieve. |
|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
|---|---|---|
GetCurrencyByKeyResult |
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.
** 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.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();
}
}
}
}