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 purchase receipt document.
Parameters
Parameter |
Type |
Description |
|---|---|---|
purchaseReceipt |
The purchase receipt 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. |
Interfaces
- Dynamics GP
- Purchasing
Examples
The following C# example creates a new purchase receipt document with the key "RCT4075". The example demonstrates setting the purchase receipt document's required key and vendor key properties. The example uses a single purchase receipt line to specify warehouse, quantity, and item information. 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;
PurchaseTransactionKey purchaseReceiptKey;
VendorKey vendorKey;
PurchaseReceipt purchaseReceipt;
PurchaseReceiptLine purchaseReceiptLine;
ItemKey itemKey;
WarehouseKey warehouseKey;
Quantity purchaseReceiptQuantity;
Policy purchaseReceiptCreatePolicy;
// 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 purchase transaction key to identify the purchase receipt
purchaseReceiptKey = new PurchaseTransactionKey();
purchaseReceiptKey.Id = "RCT4075";
// Create a vendor key object to specify the vendor for the purchase receipt
vendorKey = new VendorKey();
vendorKey.Id = "ACETRAVE0001";
// Create a purchase receipt object
purchaseReceipt = new PurchaseReceipt();
// Populate the required properties for the purchase receipt object
purchaseReceipt.Key = purchaseReceiptKey;
purchaseReceipt.VendorKey = vendorKey;
// Create a purchase receipt line object for the purchase receipt object
purchaseReceiptLine = new PurchaseReceiptLine();
// Create an item key object to specify the item
itemKey = new ItemKey();
itemKey.Id = "ACCS-CRD-12WH";
// Populate the item key property of the purchase receipt line object
purchaseReceiptLine.ItemKey = itemKey;
// Populate the vendor item number property of the purchase receipt line
purchaseReceiptLine.VendorItemNumber = "ACCS-CRD-12WH";
// Create a warehouse key object to specify the warehouse
warehouseKey = new WarehouseKey();
warehouseKey.Id = "WAREHOUSE";
// Populate the purchase receipt line's warehouse key property
purchaseReceiptLine.WarehouseKey = warehouseKey;
// Create a quantity object to specify the quantity
purchaseReceiptQuantity = new Quantity();
purchaseReceiptQuantity.Value = 1;
// Populate the shipped quantity property of the purchase receipt line
purchaseReceiptLine.QuantityShipped = purchaseReceiptQuantity;
// Create an array to hold the purchase receipt line
PurchaseReceiptLine[] lines = { purchaseReceiptLine };
// Add the array of purchase receipt lines to the purchase receipt object
purchaseReceipt.Lines = lines;
// Get the create policy for purchase receipt objects
purchaseReceiptCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
"CreatePurchaseReceipt", context);
// Create the purchase receipt
wsDynamicsGP.CreatePurchaseReceipt(purchaseReceipt, context, purchaseReceiptCreatePolicy);
}
}
}
** 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;
PurchaseTransactionKey purchaseReceiptKey;
VendorKey vendorKey;
PurchaseReceipt purchaseReceipt;
PurchaseReceiptLine purchaseReceiptLine;
ItemKey itemKey;
WarehouseKey warehouseKey;
Quantity purchaseReceiptQuantity;
Policy purchaseReceiptCreatePolicy;
// 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 purchase transaction key to identify the purchase receipt
purchaseReceiptKey = new PurchaseTransactionKey();
purchaseReceiptKey.Id = "RCT4075";
// Create a vendor key object to specify the vendor for the purchase receipt
vendorKey = new VendorKey();
vendorKey.Id = "ACETRAVE0001";
// Create a purchase receipt object
purchaseReceipt = new PurchaseReceipt();
// Populate the required properties for the purchase receipt object
purchaseReceipt.Key = purchaseReceiptKey;
purchaseReceipt.VendorKey = vendorKey;
// Create a purchase receipt line object for the purchase receipt object
purchaseReceiptLine = new PurchaseReceiptLine();
// Create an item key object to specify the item
itemKey = new ItemKey();
itemKey.Id = "ACCS-CRD-12WH";
// Populate the item key property of the purchase receipt line object
purchaseReceiptLine.ItemKey = itemKey;
// Populate the vendor item number property of the purchase receipt line
purchaseReceiptLine.VendorItemNumber = "ACCS-CRD-12WH";
// Create a warehouse key object to specify the warehouse
warehouseKey = new WarehouseKey();
warehouseKey.Id = "WAREHOUSE";
// Populate the purchase receipt line's warehouse key property
purchaseReceiptLine.WarehouseKey = warehouseKey;
// Create a quantity object to specify the quantity
purchaseReceiptQuantity = new Quantity();
purchaseReceiptQuantity.Value = 1;
// Populate the shipped quantity property of the purchase receipt line
purchaseReceiptLine.QuantityShipped = purchaseReceiptQuantity;
// Create an array to hold the purchase receipt line
PurchaseReceiptLine[] lines = { purchaseReceiptLine };
// Add the array of purchase receipt lines to the purchase receipt object
purchaseReceipt.Lines = lines;
// Get the create policy for purchase receipt objects
purchaseReceiptCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
"CreatePurchaseReceipt", context);
// Create the purchase receipt
wsDynamicsGP.CreatePurchaseReceipt(purchaseReceipt, context, purchaseReceiptCreatePolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}