This method creates a new receivables invoice document.
Parameter |
Type |
Description |
---|---|---|
receivablesInvoice |
The receivables invoice 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. |
The following C# example creates a receivables invoice document. The example populates the required Key, CustomerKey, and SalesAmount properties. All other receivables invoice properties are set to default values. The CreateReceivablesInvoice operation saves the new receivables invoice 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 invoiceKey; CustomerKey customerKey; MoneyAmount invoiceAmount; ReceivablesInvoice receivablesInvoice; Policy receivablesInvoiceCreatePolicy; // 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 invoice invoiceKey = new ReceivablesDocumentKey(); invoiceKey.Id = "INV6520"; // Create a customer key object to specify the customer customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Create a money amount object to specify the invoice amount invoiceAmount = new MoneyAmount(); invoiceAmount.Currency = "USD"; invoiceAmount.Value = 451m; // Create the receivables invoice object receivablesInvoice = new ReceivablesInvoice(); // Populate the receivables invoice object's required properties receivablesInvoice.Key = invoiceKey; receivablesInvoice.CustomerKey = customerKey; receivablesInvoice.SalesAmount = invoiceAmount; // Get the create policy for receivables invoices receivablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateReceivablesInvoice", context); // Create the receivables invoice wsDynamicsGP.CreateReceivablesInvoice(receivablesInvoice, context, receivablesInvoiceCreatePolicy); } } }
Native endpoint
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DynamicsGPWebServiceSample.DynamicsGPService; namespace DynamicsGPWebServiceSample { class Program { static void Main(string[] args) { CompanyKey companyKey; Context context; ReceivablesDocumentKey invoiceKey; CustomerKey customerKey; MoneyAmount invoiceAmount; ReceivablesInvoice receivablesInvoice; Policy receivablesInvoiceCreatePolicy; // 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 invoice invoiceKey = new ReceivablesDocumentKey(); invoiceKey.Id = "INV6520"; // Create a customer key object to specify the customer customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Create a money amount object to specify the invoice amount invoiceAmount = new MoneyAmount(); invoiceAmount.Currency = "USD"; invoiceAmount.Value = 451m; // Create the receivables invoice object receivablesInvoice = new ReceivablesInvoice(); // Populate the receivables invoice object's required properties receivablesInvoice.Key = invoiceKey; receivablesInvoice.CustomerKey = customerKey; receivablesInvoice.SalesAmount = invoiceAmount; // Get the create policy for receivables invoices receivablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateReceivablesInvoice", context); // Create the receivables invoice wsDynamicsGP.CreateReceivablesInvoice(receivablesInvoice, context, receivablesInvoiceCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }