Compartilhar via


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

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

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.

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

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