CreateSalesFulfillmentOrder


Description

This method creates a new sales fulfillment order.

Parameters

Parameter

Type

Description

salesFulfillmentOrder

SalesFulfillmentOrder

The sales fulfillment order object 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 sales fulfillment order. The example first populates the required DocumentTypeKey, CustomerKey, and BatchKey properties. The sales fulfillment order uses a sales fulfillment order line to specify the item and quantity sold. The sales fulfillment line requires the ItemKey, and Quantity properties to be populated. The sales fulfillment order key and sales fulfillment order line key are not populated. The CreateSalesInvoice operation automatically populates the empty sales fulfillment order key and sales fulfillment order line key with the next available number. All other sales fulfillment order properties are set to default values. The CreateSalesFulfillmentOrder operation saves the new sales fulfillment order.

 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;
			SalesDocumentTypeKey salesDocumentType;
			SalesFulfillmentOrder salesFulfillmentOrder;
			CustomerKey customerKey;
			BatchKey batchKey;
			SalesFulfillmentOrderLine fulfillmentOrderLine;
			ItemKey orderItemKey;
			Quantity orderQuantity;
			Policy salesFulfillmentOrderCreatePolicy;

			// 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 fulfillment order object
			salesFulfillmentOrder = new SalesFulfillmentOrder();

			// Create a sales document type key for the sales fulfillment order
			salesDocumentType = new SalesDocumentTypeKey();
			salesDocumentType.Type = SalesDocumentType.FulfillmentOrder;
			salesDocumentType.Id = "FULORD";

			// Populate the document type of the sales fulfillment order object
			salesFulfillmentOrder.DocumentTypeKey = salesDocumentType;

			// Create a customer key
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Set the customer key property of the sales fulfillment order object
			salesFulfillmentOrder.CustomerKey = customerKey;

			// Create a batch key object
			batchKey = new BatchKey();
			batchKey.Id = "FULORD";

			// Set the batch key property of the sales fulfillment order object
			salesFulfillmentOrder.BatchKey = batchKey;

			// Create a sales fulfillment order line object
			fulfillmentOrderLine = new SalesFulfillmentOrderLine();

			// Create an item key
			orderItemKey = new ItemKey();
			orderItemKey.Id = "128 SDRAM";

			// Set the item key property of the sales fulfillment order line object
			fulfillmentOrderLine.ItemKey = orderItemKey;

			//Create a quantity object
			orderQuantity = new Quantity();
			orderQuantity.Value = 1;

			// Set the quantity property of the sales fulfillment order line object
			fulfillmentOrderLine.Quantity = orderQuantity;

			// Create a array of sales fulfillment order lines
			// Initialize the array with the sales fulfillment order line object
			SalesFulfillmentOrderLine[] fulfillmentOrderLines = { fulfillmentOrderLine };

			// Add the sales fulfillment order array to the sales fulfillment order object
			salesFulfillmentOrder.Lines = fulfillmentOrderLines;

			// Get the create policy for sales fulfillment orders
			salesFulfillmentOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateSalesFulfillmentOrder", context);

			// Create the sales fulfillment order
			wsDynamicsGP.CreateSalesFulfillmentOrder(salesFulfillmentOrder,
			context, salesFulfillmentOrderCreatePolicy);
	}
}
}

 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;
			SalesDocumentTypeKey salesDocumentType;
			SalesFulfillmentOrder salesFulfillmentOrder;
			CustomerKey customerKey;
			BatchKey batchKey;
			SalesFulfillmentOrderLine fulfillmentOrderLine;
			ItemKey orderItemKey;
			Quantity orderQuantity;
			Policy salesFulfillmentOrderCreatePolicy;

			// 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 fulfillment order object
			salesFulfillmentOrder = new SalesFulfillmentOrder();

			// Create a sales document type key for the sales fulfillment order
			salesDocumentType = new SalesDocumentTypeKey();
			salesDocumentType.Type = SalesDocumentType.FulfillmentOrder;
			salesDocumentType.Id = "FULORD";

			// Populate the document type of the sales fulfillment order object
			salesFulfillmentOrder.DocumentTypeKey = salesDocumentType;

			// Create a customer key
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Set the customer key property of the sales fulfillment order object
			salesFulfillmentOrder.CustomerKey = customerKey;

			// Create a batch key object
			batchKey = new BatchKey();
			batchKey.Id = "FULORD";

			// Set the batch key property of the sales fulfillment order object
			salesFulfillmentOrder.BatchKey = batchKey;

			// Create a sales fulfillment order line object
			fulfillmentOrderLine = new SalesFulfillmentOrderLine();

			// Create an item key
			orderItemKey = new ItemKey();
			orderItemKey.Id = "128 SDRAM";

			// Set the item key property of the sales fulfillment order line object
			fulfillmentOrderLine.ItemKey = orderItemKey;

			//Create a quantity object
			orderQuantity = new Quantity();
			orderQuantity.Value = 1;

			// Set the quantity property of the sales fulfillment order line object
			fulfillmentOrderLine.Quantity = orderQuantity;

			// Create a array of sales fulfillment order lines
			// Initialize the array with the sales fulfillment order line object
			SalesFulfillmentOrderLine[] fulfillmentOrderLines = { fulfillmentOrderLine };

			// Add the sales fulfillment order array to the sales fulfillment order object
			salesFulfillmentOrder.Lines = fulfillmentOrderLines;

			// Get the create policy for sales fulfillment orders
			salesFulfillmentOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateSalesFulfillmentOrder", context);

			// Create the sales fulfillment order
			wsDynamicsGP.CreateSalesFulfillmentOrder(salesFulfillmentOrder,
			context, salesFulfillmentOrderCreatePolicy);

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


Documentation Feedback