This method creates a new payables miscellaneous charge document.
Parameter |
Type |
Description |
---|---|---|
payablesMiscellaneousCharge |
The payables miscellaneous charge document 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 new payables miscellaneous charge document with the key “00000000000001750”. The example demonstrates setting the document’s batch key, vendor key, vendor document number, and purchases amount properties. All other properties use default values.
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; PayablesDocumentKey miscChargeKey; BatchKey batchKey; VendorKey vendorKey; PayablesMiscellaneousCharge payablesMiscellaneousCharge; Policy payablesMiscellaneousChargeCreatePolicy; // 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 payables document key object to identify the payables miscellaneous charges miscChargeKey = new PayablesDocumentKey(); miscChargeKey.Id = "00000000000001750"; // Create a batch key batchKey = new BatchKey(); batchKey.Id = "PAYABLES BATCH"; // Create a vendor key vendorKey = new VendorKey(); vendorKey.Id = "ADVANCED0001"; // Create a money amount object for the transaction MoneyAmount chargeAmount = new MoneyAmount(); chargeAmount.Currency = "USD"; chargeAmount.Value = 25m; // Create a payables miscellaneous charges object payablesMiscellaneousCharge = new PayablesMiscellaneousCharge(); // Populate the miscellaneous charges properties payablesMiscellaneousCharge.Key = miscChargeKey; payablesMiscellaneousCharge.BatchKey = batchKey; payablesMiscellaneousCharge.VendorKey = vendorKey; payablesMiscellaneousCharge.VendorDocumentNumber = "DOCUMENT 15"; payablesMiscellaneousCharge.PurchasesAmount = chargeAmount; // Get the create policy for payables miscellaneous charges payablesMiscellaneousChargeCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreatePayablesMiscellaneousCharge", context); // Create the payables miscellaneous charges wsDynamicsGP.CreatePayablesMiscellaneousCharge(payablesMiscellaneousCharge, context, payablesMiscellaneousChargeCreatePolicy); } } }
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; PayablesDocumentKey miscChargeKey; BatchKey batchKey; VendorKey vendorKey; PayablesMiscellaneousCharge payablesMiscellaneousCharge; Policy payablesMiscellaneousChargeCreatePolicy; // 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 payables document key object to identify the payables miscellaneous charges miscChargeKey = new PayablesDocumentKey(); miscChargeKey.Id = "00000000000001750"; // Create a batch key batchKey = new BatchKey(); batchKey.Id = "PAYABLES BATCH"; // Create a vendor key vendorKey = new VendorKey(); vendorKey.Id = "ADVANCED0001"; // Create a money amount object for the transaction MoneyAmount chargeAmount = new MoneyAmount(); chargeAmount.Currency = "USD"; chargeAmount.Value = 25m; // Create a payables miscellaneous charges object payablesMiscellaneousCharge = new PayablesMiscellaneousCharge(); // Populate the miscellaneous charges properties payablesMiscellaneousCharge.Key = miscChargeKey; payablesMiscellaneousCharge.BatchKey = batchKey; payablesMiscellaneousCharge.VendorKey = vendorKey; payablesMiscellaneousCharge.VendorDocumentNumber = "DOCUMENT 15"; payablesMiscellaneousCharge.PurchasesAmount = chargeAmount; // Get the create policy for payables miscellaneous charges payablesMiscellaneousChargeCreatePolicy = wsDynamicsGP.GetPolicyByOperation( "CreatePayablesMiscellaneousCharge", context); // Create the payables miscellaneous charges wsDynamicsGP.CreatePayablesMiscellaneousCharge(payablesMiscellaneousCharge, context, payablesMiscellaneousChargeCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }