Updates the specified vendor address object, storing the current values in the database.
Parameter |
Type |
Description |
---|---|---|
address |
The vendor address object that is being updated. |
|
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. |
The following C# example updates the vendor address with the vendor address key value of “PRIMARY” and a vendor key value of “ACETRAVE0001”. The update sets the Line2 property to a value of “Suite 5A”. The UpdateVendorAddress operation saves the new address 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; Policy vendorAddressPolicy; VendorKey vendorKey; VendorAddressKey vendorAddressKey; VendorAddress vendorAddress; // Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); // Be sure that default credentials are being 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 a vendor key object specifying the vendor vendorKey = new VendorKey(); vendorKey.Id = "ACETRAVE0001"; // Create a vendor address key object specifying the vendor address to be updated vendorAddressKey = new VendorAddressKey(); vendorAddressKey.VendorKey = vendorKey; vendorAddressKey.Id = "PRIMARY"; // Create the vendor address object and set the Line2 property vendorAddress = new VendorAddress(); vendorAddress.Key = vendorAddressKey; vendorAddress.Line2 = "Suite 5A"; // Create the vendor address policy object vendorAddressPolicy = wsDynamicsGP.GetPolicyByOperation("UpdateVendorAddress", context); // Update the vendor address wsDynamicsGP.UpdateVendorAddress(vendorAddress, context, vendorAddressPolicy); } } }
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; Policy vendorAddressPolicy; VendorKey vendorKey; VendorAddressKey vendorAddressKey; VendorAddress vendorAddress; // 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 a vendor key object specifying the vendor vendorKey = new VendorKey(); vendorKey.Id = "ACETRAVE0001"; // Create a vendor address key object specifying the vendor address to be updated vendorAddressKey = new VendorAddressKey(); vendorAddressKey.VendorKey = vendorKey; vendorAddressKey.Id = "PRIMARY"; // Create the vendor address object and set the Line2 property vendorAddress = new VendorAddress(); vendorAddress.Key = vendorAddressKey; vendorAddress.Line2 = "Suite 5A"; // Create the vendor address policy object vendorAddressPolicy = wsDynamicsGP.GetPolicyByOperation("UpdateVendorAddress", context); // Update the vendor address wsDynamicsGP.UpdateVendorAddress(vendorAddress, context, vendorAddressPolicy); // Close the service if(wsDynamicsGP.State != CommunicationState.Faulted) { wsDynamicsGP.Close(); } } } }