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 sales backorder.
Parameters
Parameter |
Type |
Description |
|---|---|---|
salesBackorder |
The sales backorder 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
- Sales
Examples
The following C# example creates a sales backorder. The example first populates the required Type, CustomerKey, and BatchKey properties. The sales backorder uses a sales backorder line to specify the item and quantity backordered. The sales backorder line requires the ItemKey, and Quantity properties to be populated. The sales backorder key and sales invoice line key are not populated. The CreateSalesBackorder operation automatically populates the empty sales backorder key and sales backorder line key with the next available backorder number. All other sales backorder properties are set to default values. The CreateSalesBackorder operation saves the new sales backorder.
** 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;
SalesBackorder salesBackorder;
Policy salesBackorderCreatePolicy;
// 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 sales backorder object
salesBackorder = new SalesBackorder();
// Create a document type key for the sales backorder
SalesDocumentTypeKey salesBackorderType = new SalesDocumentTypeKey();
salesBackorderType.Type = SalesDocumentType.Backorder;
// Populate the document type key of the sales backorder object
salesBackorder.DocumentTypeKey = salesBackorderType;
// Create a customer key
CustomerKey customerKey = new CustomerKey();
customerKey.Id = "AARONFIT0001";
// Populate the customer key of the sales backorder
salesBackorder.CustomerKey = customerKey;
// Create a batch key
BatchKey batchKey = new BatchKey();
batchKey.Id = "SALES BACKORDER";
// Populate the batch key of the sales backorder
salesBackorder.BatchKey = batchKey;
// Create a sales backorder line to specify the backordered item
SalesBackorderLine salesBackorderLine = new SalesBackorderLine();
// Create an item key
ItemKey itemKey = new ItemKey();
itemKey.Id = "32X IDE";
// Populate the item key property of the sales invoice line object
salesBackorderLine.ItemKey = itemKey;
// Create a sales backorder quantity object
Quantity backorderCount = new Quantity();
backorderCount.Value = 1;
// Populate the quantity of the sales backorder line object
salesBackorderLine.Quantity = backorderCount;
// Create an array of sales backorder objects
// Initialize the array with the sales backorder line object
SalesBackorderLine[] backorderLines = { salesBackorderLine };
// Add the sales backorder line array to the sales backorder object
salesBackorder.Lines = backorderLines;
// Get the create policy for sales backorder objects
salesBackorderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesBackorder", context);
// Create the sales backorder
wsDynamicsGP.CreateSalesBackorder(salesBackorder, context, salesBackorderCreatePolicy);
}
}
}
** 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;
SalesBackorder salesBackorder;
Policy salesBackorderCreatePolicy;
// 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 sales backorder object
salesBackorder = new SalesBackorder();
// Create a document type key for the sales backorder
SalesDocumentTypeKey salesBackorderType = new SalesDocumentTypeKey();
salesBackorderType.Type = SalesDocumentType.Backorder;
// Populate the document type key of the sales backorder object
salesBackorder.DocumentTypeKey = salesBackorderType;
// Create a customer key
CustomerKey customerKey = new CustomerKey();
customerKey.Id = "AARONFIT0001";
// Populate the customer key of the sales backorder
salesBackorder.CustomerKey = customerKey;
// Create a batch key
BatchKey batchKey = new BatchKey();
batchKey.Id = "SALES BACKORDER";
// Populate the batch key of the sales backorder
salesBackorder.BatchKey = batchKey;
// Create a sales backorder line to specify the backordered item
SalesBackorderLine salesBackorderLine = new SalesBackorderLine();
// Create an item key
ItemKey itemKey = new ItemKey();
itemKey.Id = "32X IDE";
// Populate the item key property of the sales invoice line object
salesBackorderLine.ItemKey = itemKey;
// Create a sales backorder quantity object
Quantity backorderCount = new Quantity();
backorderCount.Value = 1;
// Populate the quantity of the sales backorder line object
salesBackorderLine.Quantity = backorderCount;
// Create an array of sales backorder objects
// Initialize the array with the sales backorder line object
SalesBackorderLine[] backorderLines = { salesBackorderLine };
// Add the sales backorder line array to the sales backorder object
salesBackorder.Lines = backorderLines;
// Get the create policy for sales backorder objects
salesBackorderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesBackorder", context);
// Create the sales backorder
wsDynamicsGP.CreateSalesBackorder(salesBackorder, context, salesBackorderCreatePolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}