UpdateVendor


Description

Updates the specified vendor object, storing the current values in the database.

Parameters

Parameter

Type

Description

vendor

Vendor

The vendor object that is being updated.

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 updates the vendor name to “A Travel Company, Inc.” for the vendor with the key value “ACETRAVE0001”. The UpdateVendor operation saves the newly assigned name value to the database.

 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;
			VendorKey vendorKey;
			Vendor vendor;
			Policy vendorPolicy;

			// Create an instance of the service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure the default credentials are being used
			wsDynamicsGP.UseDefaultCredentials = true;

			// Create a context object 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
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Specify the vendor to be updated
			vendorKey = new VendorKey();
			vendorKey.Id = "ACETRAVE0001";

			// Create the vendor object and set the value of the field to be updated
			vendor = new Vendor();
			vendor.Name = "A Travel Company, Inc.";
			vendor.Key = vendorKey;

			// Get the update policy for vendor
			vendorPolicy = wsDynamicsGP.GetPolicyByOperation("UpdateVendor", context);

			// Update the vendor information
			wsDynamicsGP.UpdateVendor(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;
			VendorKey vendorKey;
			Vendor vendor;
			Policy vendorPolicy;

			// Create an instance of the service
			DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

			// Create a context object 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
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Specify the vendor to be updated
			vendorKey = new VendorKey();
			vendorKey.Id = "ACETRAVE0001";

			// Create the vendor object and set the value of the field to be updated
			vendor = new Vendor();
			vendor.Name = "A Travel Company, Inc.";
			vendor.Key = vendorKey;

			// Get the update policy for vendor
			vendorPolicy = wsDynamicsGP.GetPolicyByOperation("UpdateVendor", context);

			// Update the vendor information
			wsDynamicsGP.UpdateVendor(vendor, context, vendorPolicy);

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


Documentation Feedback