Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Description
This method creates a new vendor.
Parameters
Parameter |
Type |
Description |
|---|---|---|
vendor |
The 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
- Purchasing
Examples
The following C# example creates a vendor with the key value "NewVendor001". The Name property is set, and all other properties are left as 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;
Vendor vendor;
VendorKey vendorKey;
Policy vendorPolicy;
// Create an instance of the service
DynamicsGP wsDynamicsGP = new DynamicsGP();
// Be sure the default credential are being used
wsDynamicsGP.UseDefaultCredentials = true;
// Create a context object with which to call the service
context = new Context();
// Specify which comany to use (sample company)
companyKey = new CompanyKey();
companyKey.Id = (-1);
// Set up the context
context.OrganizationKey = (OrganizationKey)companyKey;
// Create a new vendor key
vendorKey = new VendorKey();
vendorKey.Id = "NewVndr001";
// Populate the vendor object
vendor = new Vendor();
vendor.Key = vendorKey;
vendor.Name = "New Vendor 001";
// Get the create policy for vendor
vendorPolicy = wsDynamicsGP.GetPolicyByOperation("CreateVendor", context);
// Create the vendor
wsDynamicsGP.CreateVendor(vendor, context, vendorPolicy);
}
}
}
** 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;
Vendor vendor;
VendorKey vendorKey;
Policy vendorPolicy;
// Create an instance of the service
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
// Be sure the default credential are being used
// Create a context object with which to call the service
context = new Context();
// Specify which comany to use (sample company)
companyKey = new CompanyKey();
companyKey.Id = (-1);
// Set up the context
context.OrganizationKey = (OrganizationKey)companyKey;
// Create a new vendor key
vendorKey = new VendorKey();
vendorKey.Id = "NewVndr001";
// Populate the vendor object
vendor = new Vendor();
vendor.Key = vendorKey;
vendor.Name = "New Vendor 001";
// Get the create policy for vendor
vendorPolicy = wsDynamicsGP.GetPolicyByOperation("CreateVendor", context);
// Create the vendor
wsDynamicsGP.CreateVendor(vendor, context, vendorPolicy);
// Close the service
if(wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
}
}