CreateKit


Description

This method creates a new kit inventory item.

Parameters

Parameter

Type

Description

kit

Kit

The kit inventory item 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 kit inventory item with the key “TESTKIT001”. The example creates a kit consisting of two kit components. The kit components include a phone that has an inventory item key of “100XLG“ and a headset with an inventory item key of “ACCS-HDS-1EAR“. The example also populates the description, unit of measure, component key and quantity properties. 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;
			Quantity quantity;
			KitComponentKey phoneKitComponentKey;
			KitComponentKey headsetKitComponentKey;
			KitComponent phoneKitComponent;
			KitComponent headsetKitComponent;
			ItemKey kitItemKey;
			ItemKey phoneComponentItemKey;
			ItemKey headsetComponentItemKey;
			UofMScheduleKey unitOfMeasureScheduleKey;
			Kit kit;
			Policy kitCreatePolicy;

			// 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 key object to identify the kit object
			kitItemKey = new ItemKey();
			kitItemKey.Id = "TESTKIT001";

			// Create a unit of measure schedule object for the kit object
			unitOfMeasureScheduleKey = new UofMScheduleKey();
			unitOfMeasureScheduleKey.Id = "Each";

			// Create a quantity object to specify the quantity for the kit components
			quantity = new Quantity();
			quantity.Value = 1;

			// Create the kit object
			kit = new Kit();

			// Add the key object to the kit object
			kit.Key = kitItemKey;
			kit.Description = "A test kit for web services";
			kit.UofMScheduleKey = unitOfMeasureScheduleKey;

			// Create a kit component object for a phone item:
			// Create a item key to specify the item for the kit component object
			phoneComponentItemKey = new ItemKey();
			phoneComponentItemKey.Id = "100XLG";

			// Create a kit component key to identify the kit component object
			phoneKitComponentKey = new KitComponentKey();
			phoneKitComponentKey.KitKey = kitItemKey;
			phoneKitComponentKey.ItemKey = phoneComponentItemKey;
			phoneKitComponentKey.UofM = "Each";

			// Create the kit Component object
			phoneKitComponent = new KitComponent();
			phoneKitComponent.Key = phoneKitComponentKey;
			phoneKitComponent.Quantity = quantity;

			// Create a kit component object for a headset item:
			// Create a item key to specify the item for the kit component object
			headsetComponentItemKey = new ItemKey();
			headsetComponentItemKey.Id = "ACCS-HDS-1EAR";

			// Create a kit component key to identify the kit component object
			headsetKitComponentKey = new KitComponentKey();
			headsetKitComponentKey.KitKey = kitItemKey;
			headsetKitComponentKey.ItemKey = headsetComponentItemKey;
			headsetKitComponentKey.UofM = "Each";

			// Create the kit Component object
			headsetKitComponent = new KitComponent();
			headsetKitComponent.Key = headsetKitComponentKey;
			headsetKitComponent.Quantity = quantity;

			// Create an array of the kit component objects
			KitComponent[] components = { phoneKitComponent, headsetKitComponent };

			// Add the array to the kit object
			kit.Components = components;

			// Get the create policy for kit objects
			kitCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateKit", context);

			// Create the kit
			wsDynamicsGP.CreateKit(kit, context, kitCreatePolicy);
	}
}
}

 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;
			Quantity quantity;
			KitComponentKey phoneKitComponentKey;
			KitComponentKey headsetKitComponentKey;
			KitComponent phoneKitComponent;
			KitComponent headsetKitComponent;
			ItemKey kitItemKey;
			ItemKey phoneComponentItemKey;
			ItemKey headsetComponentItemKey;
			UofMScheduleKey unitOfMeasureScheduleKey;
			Kit kit;
			Policy kitCreatePolicy;

			// 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 key object to identify the kit object
			kitItemKey = new ItemKey();
			kitItemKey.Id = "TESTKIT001";

			// Create a unit of measure schedule object for the kit object
			unitOfMeasureScheduleKey = new UofMScheduleKey();
			unitOfMeasureScheduleKey.Id = "Each";

			// Create a quantity object to specify the quantity for the kit components
			quantity = new Quantity();
			quantity.Value = 1;

			// Create the kit object
			kit = new Kit();

			// Add the key object to the kit object
			kit.Key = kitItemKey;
			kit.Description = "A test kit for web services";
			kit.UofMScheduleKey = unitOfMeasureScheduleKey;

			// Create a kit component object for a phone item:
			// Create a item key to specify the item for the kit component object
			phoneComponentItemKey = new ItemKey();
			phoneComponentItemKey.Id = "100XLG";

			// Create a kit component key to identify the kit component object
			phoneKitComponentKey = new KitComponentKey();
			phoneKitComponentKey.KitKey = kitItemKey;
			phoneKitComponentKey.ItemKey = phoneComponentItemKey;
			phoneKitComponentKey.UofM = "Each";

			// Create the kit Component object
			phoneKitComponent = new KitComponent();
			phoneKitComponent.Key = phoneKitComponentKey;
			phoneKitComponent.Quantity = quantity;

			// Create a kit component object for a headset item:
			// Create a item key to specify the item for the kit component object
			headsetComponentItemKey = new ItemKey();
			headsetComponentItemKey.Id = "ACCS-HDS-1EAR";

			// Create a kit component key to identify the kit component object
			headsetKitComponentKey = new KitComponentKey();
			headsetKitComponentKey.KitKey = kitItemKey;
			headsetKitComponentKey.ItemKey = headsetComponentItemKey;
			headsetKitComponentKey.UofM = "Each";

			// Create the kit Component object
			headsetKitComponent = new KitComponent();
			headsetKitComponent.Key = headsetKitComponentKey;
			headsetKitComponent.Quantity = quantity;

			// Create an array of the kit component objects
			KitComponent[] components = { phoneKitComponent, headsetKitComponent };

			// Add the array to the kit object
			kit.Components = components;

			// Get the create policy for kit objects
			kitCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateKit", context);

			// Create the kit
			wsDynamicsGP.CreateKit(kit, context, kitCreatePolicy);

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


Documentation Feedback