GetVendorAddressByKey


Description

Retrieves a single vendor address object based on the specified vendor address key.

Parameters

Parameter

Type

Description

key

VendorAddressKey

The vendor address key object that specifiest the vendor address to retrieve.

context

Context

Specifies information about how the method will be called.


Return Value:

Value

Type

Description

GetVendorAddressByKeyResult

VendorAddress

The vendor address.


Interfaces

 

Examples

The following C# example retrieves the primary address for the vendor with the key value “ACETRAVE0001”. The city from the vendor’s address is displayed in a message box.

 Legacy endpoint

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			Context context;
			VendorKey vendorKey;
			VendorAddress vendorAddress;
			VendorAddressKey vendorAddressKey;

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

			// Be sure the 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 and specify the vendor
			vendorKey = new VendorKey();
			vendorKey.Id = "ACETRAVE0001";

			// Create the vendor key object
			vendorAddressKey = new VendorAddressKey();
			vendorAddressKey.VendorKey = vendorKey;
			vendorAddressKey.Id = "PRIMARY";

			// Retrieve the vendor address object
			vendorAddress = wsDynamicsGP.GetVendorAddressByKey(vendorAddressKey, context);

			// Display location information for the vendor
			MessageBox.Show("City: " + vendorAddress.City);
	}
}
}

 Native endpoint

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			Context context;
			VendorKey vendorKey;
			VendorAddress vendorAddress;
			VendorAddressKey vendorAddressKey;

			// 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 and specify the vendor
			vendorKey = new VendorKey();
			vendorKey.Id = "ACETRAVE0001";

			// Create the vendor key object
			vendorAddressKey = new VendorAddressKey();
			vendorAddressKey.VendorKey = vendorKey;
			vendorAddressKey.Id = "PRIMARY";

			// Retrieve the vendor address object
			vendorAddress = wsDynamicsGP.GetVendorAddressByKey(vendorAddressKey, context);

			// Display location information for the vendor
			MessageBox.Show("City: " + vendorAddress.City);

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


Documentation Feedback