CreateReceivablesCreditMemo


Description

This method creates a new receivables credit memo document.

Parameters

Parameter

Type

Description

receivablesCreditMemo

ReceivablesCreditMemo

The receivables credit memo object being created.

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 creates a receivables credit memo document. The example populates the required Key, CustomerKey, and SalesAmount properties. All other receivables credit memo properties are set to default values. The CreateReceivablesCreditMemo operation saves the new receivables credit memo document.

 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;
			ReceivablesDocumentKey creditMemoKey;
			CustomerKey customerKey;
			MoneyAmount creditMemoAmount;
			ReceivablesCreditMemo receivablesCreditMemo;
			Policy receivablesCreditMemoCreatePolicy;

			// 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 the document key to uniquely identify the receivables credit memo
			creditMemoKey = new ReceivablesDocumentKey();
			creditMemoKey.Id = "CM6500";

			// Create a customer key object to specify the customer
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Create a money amount object to specify the credit memo amount
			creditMemoAmount = new MoneyAmount();
			creditMemoAmount.Currency = "USD";
			creditMemoAmount.Value = 158m;

			// Create the receivables credit memo object
			receivablesCreditMemo = new ReceivablesCreditMemo();

			// Populate the receivables credit memo object's required properties
			receivablesCreditMemo.Key = creditMemoKey;
			receivablesCreditMemo.CustomerKey = customerKey;
			receivablesCreditMemo.SalesAmount = creditMemoAmount;

			// Get the create policy for receivables credit memo objects
			receivablesCreditMemoCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateReceivablesCreditMemo", context);

			// Create the receivables credit memo
			wsDynamicsGP.CreateReceivablesCreditMemo(receivablesCreditMemo,
			context, receivablesCreditMemoCreatePolicy);
	}
}
}

 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;
			ReceivablesDocumentKey creditMemoKey;
			CustomerKey customerKey;
			MoneyAmount creditMemoAmount;
			ReceivablesCreditMemo receivablesCreditMemo;
			Policy receivablesCreditMemoCreatePolicy;

			// 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 the document key to uniquely identify the receivables credit memo
			creditMemoKey = new ReceivablesDocumentKey();
			creditMemoKey.Id = "CM6500";

			// Create a customer key object to specify the customer
			customerKey = new CustomerKey();
			customerKey.Id = "AARONFIT0001";

			// Create a money amount object to specify the credit memo amount
			creditMemoAmount = new MoneyAmount();
			creditMemoAmount.Currency = "USD";
			creditMemoAmount.Value = 158m;

			// Create the receivables credit memo object
			receivablesCreditMemo = new ReceivablesCreditMemo();

			// Populate the receivables credit memo object's required properties
			receivablesCreditMemo.Key = creditMemoKey;
			receivablesCreditMemo.CustomerKey = customerKey;
			receivablesCreditMemo.SalesAmount = creditMemoAmount;

			// Get the create policy for receivables credit memo objects
			receivablesCreditMemoCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateReceivablesCreditMemo", context);

			// Create the receivables credit memo
			wsDynamicsGP.CreateReceivablesCreditMemo(receivablesCreditMemo,
			context, receivablesCreditMemoCreatePolicy);

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


Documentation Feedback