GetInventoryTransferByKey


Description

Retrieves a single inventory transfer object based on the inventory key value supplied.

Parameters

Parameter

Type

Description

key

InventoryKey

An inventory key object that specifies the inventory transfer object to retrieve.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetInventoryTransferByKeyResult

InventoryTransfer

An inventory transfer object.


Interfaces

 

Examples

The following C# example retrieves the inventory transfer object with an inventory key equal to “00000000000000002”. A message box displays the number of inventory transfer lines associated with the specified inventory transfer object.

 Legacy endpoint

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			Context context;
			InventoryKey inventoryKey;
			InventoryTransfer inventoryTransfer;

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

			// Retrieve the inventory transfer object
			inventoryTransfer = wsDynamicsGP.GetInventoryTransferByKey(inventoryKey, context);

			// Display the number of line items for the inventory transfer object
			MessageBox.Show("Number of inventory transfer lines: " +
			inventoryTransfer.Lines.Length.ToString());
	}
}
}

 Native endpoint

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			Context context;
			InventoryKey inventoryKey;
			InventoryTransfer inventoryTransfer;

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

			// Retrieve the inventory transfer object
			inventoryTransfer = wsDynamicsGP.GetInventoryTransferByKey(inventoryKey, context);

			// Display the number of line items for the inventory transfer object
			MessageBox.Show("Number of inventory transfer lines: " +
			inventoryTransfer.Lines.Length.ToString());

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


Documentation Feedback