Share via


UpdateVendorAddress

Description

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

Parameters

Parameter

Type

Description

address

VendorAddress

The vendor address 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

  • Dynamics GP
  • Purchasing

Examples

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.

Cc508577.LegacyEndpoint(en-us,MSDN.10).gif** 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);
        }
    }
}

Cc508577.NativeEndpoint(en-us,MSDN.10).gif** 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;
            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();
            }
        }
    }
}