GetGLTransactionByKey
Description
Retrieves a single general ledger transaction object based on the key value supplied.
Parameters
Parameter |
Type |
Description |
---|---|---|
key |
A GL transaction key object that specifies the GL transaction to retrieve. |
|
context |
Specifies information about how the method will be called. |
Return Value:
Value |
Type |
Description |
---|---|---|
GetGLTransactionByKeyResult |
A GL transaction object. |
Interfaces
- Dynamics GP
- Financials
Examples
The following C# example retrieves the GL transaction.with the journal Id value of "3327" and a transaction date of "4/21/2007". The transaction's source document value 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; DateTime transactionDate; GLTransactionKey transactionKey; 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 data object // Specify the date of the transaction transactionDate = new DateTime(2007, 4, 21); // Create a GL transaction key to specify the transaction transactionKey = new GLTransactionKey(); transactionKey.JournalId = 3327; transactionKey.Date = transactionDate; // Retrieve the GL transaction object transaction = wsDynamicsGP.GetGLTransactionByKey(transactionKey, context); // Display the source document of the transaction MessageBox.Show("Source document: " + transaction.SourceDocumentKey.Id); } } }
** 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; DateTime transactionDate; GLTransactionKey transactionKey; 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 data object // Specify the date of the transaction transactionDate = new DateTime(2007, 4, 21); // Create a GL transaction key to specify the transaction transactionKey = new GLTransactionKey(); transactionKey.JournalId = 3327; transactionKey.Date = transactionDate; // Retrieve the GL transaction object transaction = wsDynamicsGP.GetGLTransactionByKey(transactionKey, context); // Display the source document of the transaction MessageBox.Show("Source document: " + transaction.SourceDocumentKey.Id); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }