GetCurrencyPostingAccountByKey


Description

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

Parameters

Parameter

Type

Description

key

CurrencyPostingAccountKey

The currency posting account key object that specifies the currency posting account object to retrieve.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetCurrencyPostingAccountByKeyResult

CurrencyPostingAccount

A currency posting account object.


Interfaces

 

Examples

The following C# example retrieves the currency posting account object with the key value “NZD”, containing the posting accounts configured to work with New Zealand dollars. The account number for the Realized Gain account 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)
		{
			CompanyKey companyKey;
			Context context;
			CurrencyPostingAccount currencyPostingAccount;
			CurrencyPostingAccountKey currencyPostingAccountKey;
			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();

			// Specify which company to use (sample company)
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

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

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

			// Retrieve the currency posting account object
			currencyPostingAccount = wsDynamicsGP.GetCurrencyPostingAccountByKey
			(currencyPostingAccountKey, context);

			// Display the Realized Gain account
			MessageBox.Show(currencyPostingAccount.RealizedGainGLAccountKey.Id);
	}
}
}

 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)
		{
			CompanyKey companyKey;
			Context context;
			CurrencyPostingAccount currencyPostingAccount;
			CurrencyPostingAccountKey currencyPostingAccountKey;
			CurrencyKey currencyKey;

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

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

			// Specify which company to use (sample company)
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

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

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

			// Retrieve the currency posting account object
			currencyPostingAccount = wsDynamicsGP.GetCurrencyPostingAccountByKey
			(currencyPostingAccountKey, context);

			// Display the Realized Gain account
			MessageBox.Show(currencyPostingAccount.RealizedGainGLAccountKey.Id);

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


Documentation Feedback