CreateVendor


Description

This method creates a new vendor.

Parameters

Parameter

Type

Description

vendor

Vendor

The vendor 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 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 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();
		}
	}
}
}


Documentation Feedback