Retrieves the currency access object based on the key values supplied. Information in this object indicates whether a company has access to a currency defined in Microsoft Dynamics GP.
Parameter |
Type |
Description |
---|---|---|
key |
The currency access key object that specifies the company and currency. |
|
context |
Specifies information about how the method will be called. |
Value |
Type |
Description |
---|---|---|
GetCurrencyAccessByKeyResult |
The currency access object. |
The following C# example retrieves the currency access object for the sample company and the New Zealand Dollar (NZD) currency. A message box is displayed, indicating whether the sample company has access to the currency.
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; CurrencyKey currencyKey; CompanyKey companyKey; CurrencyAccessKey currencyAccessKey; CurrencyAccess currencyAccess; // 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 currency access key object, specifying the // company and currency for which access will be examined companyKey = new CompanyKey(); companyKey.Id = (-1); currencyKey = new CurrencyKey(); currencyKey.ISOCode = "NZD"; currencyAccessKey = new CurrencyAccessKey(); currencyAccessKey.CompanyKey = companyKey; currencyAccessKey.CurrencyKey = currencyKey; // Retrieve the currency access object currencyAccess = wsDynamicsGP.GetCurrencyAccessByKey(currencyAccessKey, context); // Indicate whether the company has access to the currency if (currencyAccess.IsActive == true) { MessageBox.Show("Company has access"); } else { MessageBox.Show("Company does not have access"); } } } }
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; CurrencyKey currencyKey; CompanyKey companyKey; CurrencyAccessKey currencyAccessKey; CurrencyAccess currencyAccess; // 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 currency access key object, specifying the // company and currency for which access will be examined companyKey = new CompanyKey(); companyKey.Id = (-1); currencyKey = new CurrencyKey(); currencyKey.ISOCode = "NZD"; currencyAccessKey = new CurrencyAccessKey(); currencyAccessKey.CompanyKey = companyKey; currencyAccessKey.CurrencyKey = currencyKey; // Retrieve the currency access object currencyAccess = wsDynamicsGP.GetCurrencyAccessByKey(currencyAccessKey, context); // Indicate whether the company has access to the currency if (currencyAccess.IsActive == true) { MessageBox.Show("Company has access"); } else { MessageBox.Show("Company does not have access"); } // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }