Compartilhar via


GetGLTransactionList

Description

Retrieves a list of general ledger transaction summary objects that meet the specified criteria.

Parameters

Parameter

Type

Description

criteria

GLTransactionCriteria

The GL transaction criteria object that specifies which GL transaction summaries are to be retrieved.

context

Context

Specifies information about how the method will be called.

Return Value:

Value

Type

Description

GetGLTransactionListResult

ArrayOfGLTransactionSummary

A list of the GL transaction summary objects that match the specified criteria.

Interfaces

  • Dynamics GP
  • Financials

Examples

The following C# example retrieves the list of GL transaction with a transaction state of "Work" and a batch Id of "PMCHK". A message box displays the journal Id and reference properties for each transaction.

Cc508477.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;
            ListRestrictionOfNullableOfGLTransactionState transactionStateRestriction;
            LikeRestrictionOfString batchRestriction;
            GLTransactionCriteria transactionCriteria;
            GLTransactionSummary[] transactionSummaries;

            // 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 two restriction object
            // Retrieve GL transactions with a transaction state of 'Work'
            transactionStateRestriction = new ListRestrictionOfNullableOfGLTransactionState();
            transactionStateRestriction.EqualValue = GLTransactionState.Work;

            // Retrieve GL transactions with the batch Id of 'PMCHK'
            batchRestriction = new LikeRestrictionOfString();
            batchRestriction.EqualValue = "PMCHK";

            // Create the criteria object
            transactionCriteria = new GLTransactionCriteria();
            transactionCriteria.TransactionState = transactionStateRestriction;
            transactionCriteria.BatchId = batchRestriction;

            // Retrieve the list of GL transaction summary objects
            transactionSummaries = wsDynamicsGP.GetGLTransactionList(transactionCriteria, context);

            // Display the journal ID and reference property for each member of the summary object list
            StringBuilder summaryList = new StringBuilder();
            foreach (GLTransactionSummary a in transactionSummaries)
            {
                summaryList.AppendLine("Journal Id: " + a.Key.JournalId + "  Reference: " +
                a.Reference);
            }
            MessageBox.Show(summaryList.ToString());
        }
    }
}

Cc508477.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;
            ListRestrictionOfNullableOfGLTransactionState transactionStateRestriction;
            LikeRestrictionOfstring batchRestriction;
            GLTransactionCriteria transactionCriteria;
            GLTransactionSummary[] transactionSummaries;

            // 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 two restriction object
            // Retrieve GL transactions with a transaction state of 'Work'
            transactionStateRestriction = new ListRestrictionOfNullableOfGLTransactionState();
            transactionStateRestriction.EqualValue = GLTransactionState.Work;

            // Retrieve GL transactions with the batch Id of 'PMCHK'
            batchRestriction = new LikeRestrictionOfstring();
            batchRestriction.EqualValue = "PMCHK";

            // Create the criteria object
            transactionCriteria = new GLTransactionCriteria();
            transactionCriteria.TransactionState = transactionStateRestriction;
            transactionCriteria.BatchId = batchRestriction;

            // Retrieve the list of GL transaction summary objects
            transactionSummaries = wsDynamicsGP.GetGLTransactionList(transactionCriteria, context);

            // Display the journal ID and reference property for each member of the summary object list
            StringBuilder summaryList = new StringBuilder();
            foreach (GLTransactionSummary a in transactionSummaries)
            {
                summaryList.AppendLine("Journal Id: " + a.Key.JournalId + "  Reference: " +
                a.Reference);
            }
            MessageBox.Show(summaryList.ToString());

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