Del via


GetCountryRegionCodeByKey

Description

Retrieves the country region code object based on the key values supplied.

Parameters

Parameter

Type

Description

key

CountryRegionCodeKey

The country region code key object that specifies the country region code to retrieve.

context

Context

Specifies information about how the method will be called.

Return Value:

Value

Type

Description

GetCountryRegionCodeByKeyResult

CountryRegionCode

The country region code object.

Interfaces

  • Dynamics GP
  • Common
  • Field Service
  • Financials
  • Human Resources/Payroll
  • Inventory
  • Manufacturing
  • Project Accounting
  • Purchasing
  • Sales

Examples

The following C# example retrieves the country region code with the country code "BE". This example requires Intrastat tracking to be enabled. If the country code "BE" cannot be found, an existing country region code should be used. A message box displays the description property of the country region code object.

Cc508455.LegacyEndpoint(en-us,MSDN.10).gif** 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;
            CountryRegionCodeKey countryRegionCodeKey;
            CountryRegionCode countryRegionCode;

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

            // Be sure the default credentials are 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 country region code key object to specify the country region code
            countryRegionCodeKey = new CountryRegionCodeKey();
            countryRegionCodeKey.Id = "BE";

            // Retrieve the country region code object
            countryRegionCode = wsDynamicsGP.GetCountryRegionCodeByKey(countryRegionCodeKey, context);

            // Display the description property from the country region code object
            MessageBox.Show("Country region code description: " + countryRegionCode.Description);
        }
    }
}

Cc508455.NativeEndpoint(en-us,MSDN.10).gif** Native endpoint **

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

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            CountryRegionCodeKey countryRegionCodeKey;
            CountryRegionCode countryRegionCode;

            // 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 country region code key object to specify the country region code
            countryRegionCodeKey = new CountryRegionCodeKey();
            countryRegionCodeKey.Id = "BE";

            // Retrieve the country region code object
            countryRegionCode = wsDynamicsGP.GetCountryRegionCodeByKey(countryRegionCodeKey, context);

            // Display the description property from the country region code object
            MessageBox.Show("Country region code description: " + countryRegionCode.Description);

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