GetSalesDocumentList


Description

Retrieves a list of sales document summary objects that match the specified criteria. The list may contain different types of sales documents.

Parameters

Parameter

Type

Description

criteria

SalesDocumentCriteria

A sales document criteria object that specifies which sales document summary objects are returned.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetSalesDocumentListResult

ArrayOfSalesDocumentSummary

The list of sales document summary objects that match the specified criteria.


Interfaces

 

Examples

The following C# example retrieves the list of sales document summary objects where the CustomerId property equals “AARONFIT0001“ and the TransactionState property is equal to “Work”. The list includes sales orders, sales invoices, sales returns, and sales backorders for the specified customer. The Type and TotalAmount property from each sales document summary object 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;
			LikeRestrictionOfString customerIdRestriction;
			ListRestrictionOfNullableOfSalesTransactionState transactionStateRestriction;
			SalesDocumentCriteria salesDocumentCriteria;
			SalesDocumentSummary[] salesDocumentSummary;

			// 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 customer ID restriction object
			customerIdRestriction = new LikeRestrictionOfString();
			customerIdRestriction.EqualValue = "AARONFIT0001";

			// Create a transaction state restriction object
			transactionStateRestriction = new ListRestrictionOfNullableOfSalesTransactionState();
			transactionStateRestriction.EqualValue = SalesTransactionState.Work;

			// Create a sales document criteria object
			salesDocumentCriteria = new SalesDocumentCriteria();
			salesDocumentCriteria.CustomerId = customerIdRestriction;
			salesDocumentCriteria.TransactionState = transactionStateRestriction;

			// Retrieve the sales document summary objects specified by the criteria object
			salesDocumentSummary = wsDynamicsGP.GetSalesDocumentList(salesDocumentCriteria, context);

			// Display the type and amount of each member of the summary object list
			StringBuilder summaryList = new StringBuilder();
			summaryList.AppendLine("Customer Summary for:  " + salesDocumentSummary[0].CustomerName);
			foreach (SalesDocumentSummary a in salesDocumentSummary)
			{
				summaryList.AppendLine("Document Type: " + a.Type.ToString() + "  Total amount: " +
				a.TotalAmount.Value.ToString("C"));
		}
			MessageBox.Show(summaryList.ToString());
	}
}
}

 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;
			LikeRestrictionOfstring customerIdRestriction;
			ListRestrictionOfNullableOfSalesTransactionState transactionStateRestriction;
			SalesDocumentCriteria salesDocumentCriteria;
			SalesDocumentSummary[] salesDocumentSummary;

			// 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 customer ID restriction object
			customerIdRestriction = new LikeRestrictionOfstring();
			customerIdRestriction.EqualValue = "AARONFIT0001";

			// Create a transaction state restriction object
			transactionStateRestriction = new ListRestrictionOfNullableOfSalesTransactionState();
			transactionStateRestriction.EqualValue = SalesTransactionState.Work;

			// Create a sales document criteria object
			salesDocumentCriteria = new SalesDocumentCriteria();
			salesDocumentCriteria.CustomerId = customerIdRestriction;
			salesDocumentCriteria.TransactionState = transactionStateRestriction;

			// Retrieve the sales document summary objects specified by the criteria object
			salesDocumentSummary = wsDynamicsGP.GetSalesDocumentList(salesDocumentCriteria, context);

			// Display the type and amount of each member of the summary object list
			StringBuilder summaryList = new StringBuilder();
			summaryList.AppendLine("Customer Summary for:  " + salesDocumentSummary[0].CustomerName);
			foreach (SalesDocumentSummary a in salesDocumentSummary)
			{
				summaryList.AppendLine("Document Type: " + a.Type.ToString() + "  Total amount: " +
				a.TotalAmount.Value.ToString("C"));
		}
			MessageBox.Show(summaryList.ToString());

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


Documentation Feedback