CreatePayablesInvoice


Description

This method creates a new payables invoice document.

Parameters

Parameter

Type

Description

payablesInvoice

PayablesInvoice

The payables invoice 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 invoice document with the key “00000000000001550”. 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 invoiceKey;
			BatchKey batchKey;
			VendorKey vendorKey;
			PayablesInvoice payablesInvoice;
			Policy payablesInvoiceCreatePolicy;

			// 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 invoice
			invoiceKey = new PayablesDocumentKey();
			invoiceKey.Id = "00000000000001550"; 

			// 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 purchaseAmount = new MoneyAmount();
			purchaseAmount.Currency = "USD";
			purchaseAmount.Value = 250m;

			// Create a payables invoice object
			payablesInvoice = new PayablesInvoice();

			// Populate the invoice properties
			payablesInvoice.Key = invoiceKey;
			payablesInvoice.BatchKey = batchKey;
			payablesInvoice.VendorKey = vendorKey;
			payablesInvoice.VendorDocumentNumber = "DOCUMENT 10";
			payablesInvoice.PurchasesAmount = purchaseAmount;

			// Get the create policy for payables invoices
			payablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreatePayablesInvoice", context);

			// Create the payables invoice
			wsDynamicsGP.CreatePayablesInvoice(payablesInvoice, context, payablesInvoiceCreatePolicy);
	}
}
}

 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 invoiceKey;
			BatchKey batchKey;
			VendorKey vendorKey;
			PayablesInvoice payablesInvoice;
			Policy payablesInvoiceCreatePolicy;

			// 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 invoice
			invoiceKey = new PayablesDocumentKey();
			invoiceKey.Id = "00000000000001550"; 

			// 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 purchaseAmount = new MoneyAmount();
			purchaseAmount.Currency = "USD";
			purchaseAmount.Value = 250m;

			// Create a payables invoice object
			payablesInvoice = new PayablesInvoice();

			// Populate the invoice properties
			payablesInvoice.Key = invoiceKey;
			payablesInvoice.BatchKey = batchKey;
			payablesInvoice.VendorKey = vendorKey;
			payablesInvoice.VendorDocumentNumber = "DOCUMENT 10";
			payablesInvoice.PurchasesAmount = purchaseAmount;

			// Get the create policy for payables invoices
			payablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreatePayablesInvoice", context);

			// Create the payables invoice
			wsDynamicsGP.CreatePayablesInvoice(payablesInvoice, context, payablesInvoiceCreatePolicy);

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


Documentation Feedback