Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Description
This method creates a new relationship between an item and a vendor.
Parameters
Parameter |
Type |
Description |
|---|---|---|
itemVendor |
The item vendor 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 vendor relationship between an item with the key "128 SDRAM" and a vendor with the key "ACETRAVE0001". The example uses an item key to specify the item and a vendor key to specify the vendor. The item vendor 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;
ItemVendor itemVendor;
ItemKey itemKey;
VendorKey vendorKey;
ItemVendorKey itemVendorKey;
Policy itemVendorCreatePolicy;
// 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 vendor object
itemVendor = new ItemVendor();
// Create an item key to specify the item
itemKey = new ItemKey();
itemKey.Id = "128 SDRAM";
// Create a vendor key to specify the vendor
vendorKey = new VendorKey();
vendorKey.Id = "ACETRAVE0001";
// Create an item vendor key
itemVendorKey = new ItemVendorKey();
itemVendorKey.ItemKey = itemKey;
itemVendorKey.VendorKey = vendorKey;
// Populate the item vendor objects key property
itemVendor.Key = itemVendorKey;
// Get the create policy for item vendor
itemVendorCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateItemVendor", context);
// Create the item vendor
wsDynamicsGP.CreateItemVendor(itemVendor, context, itemVendorCreatePolicy);
}
}
}
** 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;
ItemVendor itemVendor;
ItemKey itemKey;
VendorKey vendorKey;
ItemVendorKey itemVendorKey;
Policy itemVendorCreatePolicy;
// 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 vendor object
itemVendor = new ItemVendor();
// Create an item key to specify the item
itemKey = new ItemKey();
itemKey.Id = "128 SDRAM";
// Create a vendor key to specify the vendor
vendorKey = new VendorKey();
vendorKey.Id = "ACETRAVE0001";
// Create an item vendor key
itemVendorKey = new ItemVendorKey();
itemVendorKey.ItemKey = itemKey;
itemVendorKey.VendorKey = vendorKey;
// Populate the item vendor objects key property
itemVendor.Key = itemVendorKey;
// Get the create policy for item vendor
itemVendorCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateItemVendor", context);
// Create the item vendor
wsDynamicsGP.CreateItemVendor(itemVendor, context, itemVendorCreatePolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}