CreateReceivablesReturn
Description
This method creates a new receivables return document.
Parameters
Parameter |
Type |
Description |
---|---|---|
receivablesReturn |
The receivables return object being created. |
|
context |
Specifies information about how the method will be called. |
|
policy |
Specifies the set of behaviors and behavior options to be applied during the operation. |
Interfaces
- Dynamics GP
- Sales
Examples
The following C# example creates a receivables return document. The example populates the required Key, CustomerKey, and SalesAmount properties. All other receivables return properties are set to default values. The CreateReceivablesReturn operation saves the new receivables return document.
** Legacy endpoint**
using System; using System.Collections.Generic; using System.Text; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; ReceivablesDocumentKey returnKey; CustomerKey customerKey; MoneyAmount returnAmount; ReceivablesReturn receivablesReturn; Policy receivablesReturnCreatePolicy; // 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 the document key to uniquely identify the receivables return returnKey = new ReceivablesDocumentKey(); returnKey.Id = "TRN2550"; // Create a customer key object to specify the customer customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Create a money amount object to specify the return amount returnAmount = new MoneyAmount(); returnAmount.Currency = "USD"; returnAmount.Value = 68m; // Create the receivables return object receivablesReturn = new ReceivablesReturn(); // Populate the receivables return object's required properties receivablesReturn.Key = returnKey; receivablesReturn.CustomerKey = customerKey; receivablesReturn.SalesAmount = returnAmount; // Get the create policy for receivables returns receivablesReturnCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateReceivablesReturn", context); // Create the receivables return wsDynamicsGP.CreateReceivablesReturn(receivablesReturn, context, receivablesReturnCreatePolicy); } } }
** Native endpoint **
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; ReceivablesDocumentKey returnKey; CustomerKey customerKey; MoneyAmount returnAmount; ReceivablesReturn receivablesReturn; Policy receivablesReturnCreatePolicy; // 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 the document key to uniquely identify the receivables return returnKey = new ReceivablesDocumentKey(); returnKey.Id = "TRN2550"; // Create a customer key object to specify the customer customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Create a money amount object to specify the return amount returnAmount = new MoneyAmount(); returnAmount.Currency = "USD"; returnAmount.Value = 68m; // Create the receivables return object receivablesReturn = new ReceivablesReturn(); // Populate the receivables return object's required properties receivablesReturn.Key = returnKey; receivablesReturn.CustomerKey = customerKey; receivablesReturn.SalesAmount = returnAmount; // Get the create policy for receivables returns receivablesReturnCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateReceivablesReturn", context); // Create the receivables return wsDynamicsGP.CreateReceivablesReturn(receivablesReturn, context, receivablesReturnCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }