CreatePayablesFinanceCharge


Description

This method creates a new payables finance charge document.

Parameters

Parameter

Type

Description

payablesFinanceCharge

PayablesFinanceCharge

The payables finance charge document being created.

context

Context

Specifies information about how the method will be called.

policy

Policy

Specifies the set of behaviors and behavior options to be applied during the operation.


Interfaces

 

Examples

The following C# example creates a new payables finance charge document with the key “00000000000001850”. 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 financeChargeKey;
			BatchKey batchKey;
			VendorKey vendorKey;
			PayablesFinanceCharge payablesFinanceCharge;
			Policy payablesFinanceChargeCreatePolicy;

			// 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 finance charge
			financeChargeKey = new PayablesDocumentKey();
			financeChargeKey.Id = "00000000000001850";

			// 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 = 85m;

			// Create a payables finance charge object
			payablesFinanceCharge = new PayablesFinanceCharge();

			// Populate the finance charge properties
			payablesFinanceCharge.Key = financeChargeKey;
			payablesFinanceCharge.BatchKey = batchKey;
			payablesFinanceCharge.VendorKey = vendorKey;
			payablesFinanceCharge.VendorDocumentNumber = "DOCUMENT 20";
			payablesFinanceCharge.PurchasesAmount = chargeAmount;

			// Get the create policy for payables finance charge
			payablesFinanceChargeCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreatePayablesFinanceCharge", context);

			// Create the payables finance charge
			wsDynamicsGP.CreatePayablesFinanceCharge(payablesFinanceCharge,
			context, payablesFinanceChargeCreatePolicy);
	}
}
}

 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 financeChargeKey;
			BatchKey batchKey;
			VendorKey vendorKey;
			PayablesFinanceCharge payablesFinanceCharge;
			Policy payablesFinanceChargeCreatePolicy;

			// 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 finance charge
			financeChargeKey = new PayablesDocumentKey();
			financeChargeKey.Id = "00000000000001850";

			// 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 = 85m;

			// Create a payables finance charge object
			payablesFinanceCharge = new PayablesFinanceCharge();

			// Populate the finance charge properties
			payablesFinanceCharge.Key = financeChargeKey;
			payablesFinanceCharge.BatchKey = batchKey;
			payablesFinanceCharge.VendorKey = vendorKey;
			payablesFinanceCharge.VendorDocumentNumber = "DOCUMENT 20";
			payablesFinanceCharge.PurchasesAmount = chargeAmount;

			// Get the create policy for payables finance charge
			payablesFinanceChargeCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreatePayablesFinanceCharge", context);

			// Create the payables finance charge
			wsDynamicsGP.CreatePayablesFinanceCharge(payablesFinanceCharge,
			context, payablesFinanceChargeCreatePolicy);

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


Documentation Feedback