CreateInventoryTransfer


Description

This method creates a new inventory transfer document.

Parameters

Parameter

Type

Description

inventoryTransfer

InventoryTransfer

The inventory transfer 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 new inventory transfer document with the key “WSINVTRFR00000010”. The example demonstrates setting the inventory transfer document’s key, batch key, and date properties. The example uses a single inventory transfer line to specify the details of the transfer. 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;
			BatchKey batchKey;
			ItemKey itemKey;
			Quantity itemQuantity;
			WarehouseKey fromWarehouseKey;
			WarehouseKey toWarehouseKey;
			InventoryKey inventoryKey;
			InventoryLineKey inventoryLineKey;
			InventoryTransfer inventoryTransfer;
			InventoryTransferLine inventoryTransferLine;
			Policy inventoryTransferCreatePolicy;

			// 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 an inventory key to identify the inventory transfer object
			inventoryKey = new InventoryKey();
			inventoryKey.Id = "WSINVTRFR00000010";

			// Create a batch key object to specify a batch for the inventory transfer
			batchKey = new BatchKey();
			batchKey.Id = "TRANSFER 1";

			// Create an inventory transfer object
			inventoryTransfer = new InventoryTransfer();

			// Populate the inventory transfer object's required properties
			inventoryTransfer.Key = inventoryKey;
			inventoryTransfer.BatchKey = batchKey;
			inventoryTransfer.Date = DateTime.Today;

			// Create an inventory transfer line object to detail the inventory transfer
			inventoryTransferLine = new InventoryTransferLine();

			// Create an inventory line key to identify the inventory transfer line object
			inventoryLineKey = new InventoryLineKey();
			inventoryLineKey.InventoryKey = inventoryKey;

			// Create an item key object to specify the item
			itemKey = new ItemKey();
			itemKey.Id = "128 SDRAM";

			// Create a quantity object to specify the amount of the transfer
			itemQuantity = new Quantity();
			itemQuantity.Value = 5m;

			// Create a warehouse key to specify the location originating the transfer
			fromWarehouseKey = new WarehouseKey();
			fromWarehouseKey.Id = "NORTH";

			// Create a warehouse key to specify the location receiving the transfer
			toWarehouseKey = new WarehouseKey();
			toWarehouseKey.Id = "WAREHOUSE";

			// Populate the required properties of the inventory transfer line object
			inventoryTransferLine.Key = inventoryLineKey;
			inventoryTransferLine.ItemKey = itemKey;
			inventoryTransferLine.Quantity = itemQuantity;
			inventoryTransferLine.WarehouseFromKey = fromWarehouseKey;
			inventoryTransferLine.WarehouseToKey = toWarehouseKey;

			// Create an array to hold the inventory transfer line object
			InventoryTransferLine[] lines = { inventoryTransferLine };

			// Add the array of inventory transfer lines to the inventory transfer object
			inventoryTransfer.Lines = lines;

			// Get the create policy for an inventory transfer
			inventoryTransferCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateInventoryTransfer", context);

			// Create the inventory transfer
			wsDynamicsGP.CreateInventoryTransfer(inventoryTransfer,
			context, inventoryTransferCreatePolicy);
	}
}
}

 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;
			BatchKey batchKey;
			ItemKey itemKey;
			Quantity itemQuantity;
			WarehouseKey fromWarehouseKey;
			WarehouseKey toWarehouseKey;
			InventoryKey inventoryKey;
			InventoryLineKey inventoryLineKey;
			InventoryTransfer inventoryTransfer;
			InventoryTransferLine inventoryTransferLine;
			Policy inventoryTransferCreatePolicy;

			// 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 an inventory key to identify the inventory transfer object
			inventoryKey = new InventoryKey();
			inventoryKey.Id = "WSINVTRFR00000010";

			// Create a batch key object to specify a batch for the inventory transfer
			batchKey = new BatchKey();
			batchKey.Id = "TRANSFER 1";

			// Create an inventory transfer object
			inventoryTransfer = new InventoryTransfer();

			// Populate the inventory transfer object's required properties
			inventoryTransfer.Key = inventoryKey;
			inventoryTransfer.BatchKey = batchKey;
			inventoryTransfer.Date = DateTime.Today;

			// Create an inventory transfer line object to detail the inventory transfer
			inventoryTransferLine = new InventoryTransferLine();

			// Create an inventory line key to identify the inventory transfer line object
			inventoryLineKey = new InventoryLineKey();
			inventoryLineKey.InventoryKey = inventoryKey;

			// Create an item key object to specify the item
			itemKey = new ItemKey();
			itemKey.Id = "128 SDRAM";

			// Create a quantity object to specify the amount of the transfer
			itemQuantity = new Quantity();
			itemQuantity.Value = 5m;

			// Create a warehouse key to specify the location originating the transfer
			fromWarehouseKey = new WarehouseKey();
			fromWarehouseKey.Id = "NORTH";

			// Create a warehouse key to specify the location receiving the transfer
			toWarehouseKey = new WarehouseKey();
			toWarehouseKey.Id = "WAREHOUSE";

			// Populate the required properties of the inventory transfer line object
			inventoryTransferLine.Key = inventoryLineKey;
			inventoryTransferLine.ItemKey = itemKey;
			inventoryTransferLine.Quantity = itemQuantity;
			inventoryTransferLine.WarehouseFromKey = fromWarehouseKey;
			inventoryTransferLine.WarehouseToKey = toWarehouseKey;

			// Create an array to hold the inventory transfer line object
			InventoryTransferLine[] lines = { inventoryTransferLine };

			// Add the array of inventory transfer lines to the inventory transfer object
			inventoryTransfer.Lines = lines;

			// Get the create policy for an inventory transfer
			inventoryTransferCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateInventoryTransfer", context);

			// Create the inventory transfer
			wsDynamicsGP.CreateInventoryTransfer(inventoryTransfer,
			context, inventoryTransferCreatePolicy);

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


Documentation Feedback