CreateItemWarehouse
Description
This method creates a new relationship between an item and a warehouse.
Parameters
Parameter |
Type |
Description |
---|---|---|
itemWarehouse |
The item warehouse 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
- Inventory
Examples
The following C# example creates an item warehouse relationship between an item with the key "OM02865" and a warehouse with the key "NORTH". The example uses an item key to specify the item and a warehouse key to specify the warehouse. The item warehouse key combines the two keys to define the relationship. 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; ItemKey itemKey; WarehouseKey warehouseKey; ItemWarehouseKey itemWarehouseKey; ItemWarehouse itemWarehouse; Policy itemWarehouseCreatePolicy; // 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 item warehouse object itemWarehouse = new ItemWarehouse(); // Create an item key to specify the item itemKey = new ItemKey(); itemKey.Id = "OM02865"; // Create a warehouse key to specify the warehouse warehouseKey = new WarehouseKey(); warehouseKey.Id = "NORTH"; // Create an item warehouse key itemWarehouseKey = new ItemWarehouseKey(); itemWarehouseKey.ItemKey = itemKey; itemWarehouseKey.WarehouseKey = warehouseKey; // Populate the item warehouse key property itemWarehouse.Key = itemWarehouseKey; // Get the create policy for item warehouse itemWarehouseCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateItemWarehouse", context); // Create the item warehouse wsDynamicsGP.CreateItemWarehouse(itemWarehouse, context, itemWarehouseCreatePolicy); } } }
** 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; ItemKey itemKey; WarehouseKey warehouseKey; ItemWarehouseKey itemWarehouseKey; ItemWarehouse itemWarehouse; Policy itemWarehouseCreatePolicy; // 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 item warehouse object itemWarehouse = new ItemWarehouse(); // Create an item key to specify the item itemKey = new ItemKey(); itemKey.Id = "OM02865"; // Create a warehouse key to specify the warehouse warehouseKey = new WarehouseKey(); warehouseKey.Id = "NORTH"; // Create an item warehouse key itemWarehouseKey = new ItemWarehouseKey(); itemWarehouseKey.ItemKey = itemKey; itemWarehouseKey.WarehouseKey = warehouseKey; // Populate the item warehouse key property itemWarehouse.Key = itemWarehouseKey; // Get the create policy for item warehouse itemWarehouseCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateItemWarehouse", context); // Create the item warehouse wsDynamicsGP.CreateItemWarehouse(itemWarehouse, context, itemWarehouseCreatePolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }