This method creates a new receivables service repair document.
Parameter |
Type |
Description |
---|---|---|
receivablesServiceRepair |
The receivables service repair 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 service repair. The example populates the required Key, CustomerKey, and SalesAmount properties. All other receivables service repair properties are set to default values. The CreateReceivablesServiceRepair operation saves the new service repair 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 serviceRepairKey; CustomerKey customerKey; MoneyAmount repairAmount; ReceivablesServiceRepair receivablesServiceRepairs; Policy receivablesServiceRepairsCreatePolicy; // 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 service repair serviceRepairKey = new ReceivablesDocumentKey(); serviceRepairKey.Id = "SVC5551"; // Create a customer key object for the receivables service repair customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Create a money amount object to specify the repair amount repairAmount = new MoneyAmount(); repairAmount.Currency = "USD"; repairAmount.Value = 345m; // Create the receivables service repair object receivablesServiceRepairs = new ReceivablesServiceRepair(); // Populate the receivables service repair object's required properties receivablesServiceRepairs.Key = serviceRepairKey; receivablesServiceRepairs.CustomerKey = customerKey; receivablesServiceRepairs.SalesAmount = repairAmount; // Get the create policy for receivables service repairs receivablesServiceRepairsCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateReceivablesServiceRepair", context); // Create the receivables service repair wsDynamicsGP.CreateReceivablesServiceRepair(receivablesServiceRepairs, context, receivablesServiceRepairsCreatePolicy); } } }
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 serviceRepairKey; CustomerKey customerKey; MoneyAmount repairAmount; ReceivablesServiceRepair receivablesServiceRepairs; Policy receivablesServiceRepairsCreatePolicy; // 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 service repair serviceRepairKey = new ReceivablesDocumentKey(); serviceRepairKey.Id = "SVC5551"; // Create a customer key object for the receivables service repair customerKey = new CustomerKey(); customerKey.Id = "AARONFIT0001"; // Create a money amount object to specify the repair amount repairAmount = new MoneyAmount(); repairAmount.Currency = "USD"; repairAmount.Value = 345m; // Create the receivables service repair object receivablesServiceRepairs = new ReceivablesServiceRepair(); // Populate the receivables service repair object's required properties receivablesServiceRepairs.Key = serviceRepairKey; receivablesServiceRepairs.CustomerKey = customerKey; receivablesServiceRepairs.SalesAmount = repairAmount; // Get the create policy for receivables service repairs receivablesServiceRepairsCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreateReceivablesServiceRepair", context); // Create the receivables service repair wsDynamicsGP.CreateReceivablesServiceRepair(receivablesServiceRepairs, context, receivablesServiceRepairsCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }