Retrieves a single general ledger transaction object based on the key value supplied.
Parameter |
Type |
Description |
---|---|---|
key |
A GL transaction posted key object that specifies the GL transaction to retrieve. |
|
context |
Specifies information about how the method will be called. |
Value |
Type |
Description |
---|---|---|
GetGLPostedTransactionByKeyResult |
A GL transaction object. |
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.
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); } } }
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; 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(); } } } }