Compartilhar via


GetGLPostedTransactionByKey

Description

Retrieves a single general ledger transaction object based on the key value supplied.

Parameters

Parameter

Type

Description

key

GLTransactionPostedKey

A GL transaction posted key object that specifies the GL transaction to retrieve.

context

Context

Specifies information about how the method will be called.

Return Value:

Value

Type

Description

GetGLPostedTransactionByKeyResult

GLTransaction

A GL transaction object.

Interfaces

  • Dynamics GP
  • Financials

Examples

The following C# example retrieves a single posted GL transaction. The example uses a GL posted transaction key object to retrieve the company's first GL transaction. A message box displays the GL transaction's reference and posted by properties.

Cc508482.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;
            GLTransactionPostedKey transactionPostedKey;
            GLTransaction transaction;

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

            // Be sure the default credentials are 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 object
            context.OrganizationKey = (OrganizationKey)companyKey;

            // Create a GL transaction posted key to specify the transaction
            transactionPostedKey = new GLTransactionPostedKey();
            transactionPostedKey.JournalId = 1;
            transactionPostedKey.Date = new DateTime(2003, 12, 31);
            transactionPostedKey.FiscalYear = 2004;
            transactionPostedKey.RecurringTransactionSequence = 1;

            // Retrieve the GL transaction object
            transaction = wsDynamicsGP.GetGLPostedTransactionByKey(transactionPostedKey, context);

            // Display the reference and posted by properties of the transaction object
            MessageBox.Show("Reference: " + transaction.Reference + "  Posted by: " + transaction.PostedBy);
        }
    }
}

Cc508482.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;
            GLTransactionPostedKey transactionPostedKey;
            GLTransaction transaction;

            // 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 object
            context.OrganizationKey = (OrganizationKey)companyKey;

            // Create a GL transaction posted key to specify the transaction
            transactionPostedKey = new GLTransactionPostedKey();
            transactionPostedKey.JournalId = 1;
            transactionPostedKey.Date = new DateTime(2003, 12, 31);
            transactionPostedKey.FiscalYear = 2004;
            transactionPostedKey.RecurringTransactionSequence = 1;

            // Retrieve the GL transaction object
            transaction = wsDynamicsGP.GetGLPostedTransactionByKey(transactionPostedKey, context);

            // Display the reference and posted by properties of the transaction object
            MessageBox.Show("Reference: " + transaction.Reference + "  Posted by: " + transaction.PostedBy);

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