Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Description
This method creates a new payables return document.
Parameters
Parameter |
Type |
Description |
|---|---|---|
payablesReturn |
The payables return 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. |
Interfaces
- Dynamics GP
- Purchasing
Examples
The following C# example creates a new payables return document with the key "00000000000001600". 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 returnKey;
BatchKey batchKey;
VendorKey vendorKey;
MoneyAmount returnAmount;
PayablesReturn payablesReturn;
Policy payablesReturnCreatePolicy;
// 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 return
returnKey = new PayablesDocumentKey();
returnKey.Id = "00000000000001600";
// 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
returnAmount = new MoneyAmount();
returnAmount.Currency = "USD";
returnAmount.Value = 70m;
// Create a payables return object
payablesReturn = new PayablesReturn();
// Populate the return properties
payablesReturn.Key = returnKey;
payablesReturn.BatchKey = batchKey;
payablesReturn.VendorKey = vendorKey;
payablesReturn.VendorDocumentNumber = "DOCUMENT 10";
payablesReturn.PurchasesAmount = returnAmount;
// Get the create policy for payables returns
payablesReturnCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
"CreatePayablesReturn", context);
// Create the payables return
wsDynamicsGP.CreatePayablesReturn(payablesReturn, context, payablesReturnCreatePolicy);
}
}
}
** Native endpoint **
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using DynamicsGPWebServiceSample.DynamicsGPService;
namespace DynamicsGPWebServiceSample
{
class Program
{
static void Main(string[] args)
{
CompanyKey companyKey;
Context context;
PayablesDocumentKey returnKey;
BatchKey batchKey;
VendorKey vendorKey;
MoneyAmount returnAmount;
PayablesReturn payablesReturn;
Policy payablesReturnCreatePolicy;
// 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 return
returnKey = new PayablesDocumentKey();
returnKey.Id = "00000000000001600";
// 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
returnAmount = new MoneyAmount();
returnAmount.Currency = "USD";
returnAmount.Value = 70m;
// Create a payables return object
payablesReturn = new PayablesReturn();
// Populate the return properties
payablesReturn.Key = returnKey;
payablesReturn.BatchKey = batchKey;
payablesReturn.VendorKey = vendorKey;
payablesReturn.VendorDocumentNumber = "DOCUMENT 10";
payablesReturn.PurchasesAmount = returnAmount;
// Get the create policy for payables returns
payablesReturnCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
"CreatePayablesReturn", context);
// Create the payables return
wsDynamicsGP.CreatePayablesReturn(payablesReturn, context, payablesReturnCreatePolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}