DeleteCustomerAddress


Description

Deletes a customer address based on the key value supplied.

Parameters

Parameter

Type

Description

key

CustomerAddressKey

The customer address key object that specifies the customer address to delete.

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 deletes the customer address with the key value “BILLING” for the customer with a key value of “AARONFIT0001”. The “BILLING” customer address used in this example was created by the CreateCustomerAddress example.

 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;
			CustomerKey customerKey;
			CustomerAddressKey customerAddressKey;
			Policy customerAddressDeletePolicy;

			// 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 customer key to specify the customer
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Create a customer address key
			customerAddressKey = new CustomerAddressKey();
			customerAddressKey.CustomerKey = customerKey;
			customerAddressKey.Id = "BILLING";

			// Get the delete policy for customer address
			customerAddressDeletePolicy = wsDynamicsGP.GetPolicyByOperation("DeleteCustomerAddress",
			context);

			// Delete the customer address
			wsDynamicsGP.DeleteCustomerAddress(customerAddressKey, context, customerAddressDeletePolicy);
	}
}
}

 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;
			CustomerKey customerKey;
			CustomerAddressKey customerAddressKey;
			Policy customerAddressDeletePolicy;

			// 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 customer key to specify the customer
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Create a customer address key
			customerAddressKey = new CustomerAddressKey();
			customerAddressKey.CustomerKey = customerKey;
			customerAddressKey.Id = "BILLING";

			// Get the delete policy for customer address
			customerAddressDeletePolicy = wsDynamicsGP.GetPolicyByOperation("DeleteCustomerAddress",
			context);

			// Delete the customer address
			wsDynamicsGP.DeleteCustomerAddress(customerAddressKey, context, customerAddressDeletePolicy);

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


Documentation Feedback