CreateReceivablesWarranty


Description

This method creates a new receivables warranty document.

Parameters

Parameter

Type

Description

receivablesWarranty

ReceivablesWarranty

The receivables warranty 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 warranty document. The example populates the required Key, CustomerKey, and SalesAmount properties. All other receivables warranty properties are set to default values. The CreateReceivablesWarranty operation saves the new receivables warranty 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 warrantyKey;
			CustomerKey customerKey;
			MoneyAmount warrantyAmount;
			ReceivablesWarranty receivablesWarranty;
			Policy receivablesWarrantyCreatePolicy;

			// 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 warranty
			warrantyKey = new ReceivablesDocumentKey();
			warrantyKey.Id = "WRN6500";

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

			// Create a money amount object to specify the warranty amount
			warrantyAmount = new MoneyAmount();
			warrantyAmount.Currency = "USD";
			warrantyAmount.Value = 205m;

			// Create the receivables warranty object
			receivablesWarranty = new ReceivablesWarranty();

			// Populate the receivables warranty object's required properties
			receivablesWarranty.Key = warrantyKey;
			receivablesWarranty.CustomerKey = customerKey;
			receivablesWarranty.SalesAmount = warrantyAmount;

			// Get the create policy for receivables warranty
			receivablesWarrantyCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateReceivablesWarranty", context);

			// Create the receivables warranty
			wsDynamicsGP.CreateReceivablesWarranty(receivablesWarranty, 
			context, receivablesWarrantyCreatePolicy);
	}
}
}

 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 warrantyKey;
			CustomerKey customerKey;
			MoneyAmount warrantyAmount;
			ReceivablesWarranty receivablesWarranty;
			Policy receivablesWarrantyCreatePolicy;

			// 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 warranty
			warrantyKey = new ReceivablesDocumentKey();
			warrantyKey.Id = "WRN6500";

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

			// Create a money amount object to specify the warranty amount
			warrantyAmount = new MoneyAmount();
			warrantyAmount.Currency = "USD";
			warrantyAmount.Value = 205m;

			// Create the receivables warranty object
			receivablesWarranty = new ReceivablesWarranty();

			// Populate the receivables warranty object's required properties
			receivablesWarranty.Key = warrantyKey;
			receivablesWarranty.CustomerKey = customerKey;
			receivablesWarranty.SalesAmount = warrantyAmount;

			// Get the create policy for receivables warranty
			receivablesWarrantyCreatePolicy = wsDynamicsGP.GetPolicyByOperation(
			"CreateReceivablesWarranty", context);

			// Create the receivables warranty
			wsDynamicsGP.CreateReceivablesWarranty(receivablesWarranty, 
			context, receivablesWarrantyCreatePolicy);

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


Documentation Feedback