CreateSalesQuote


Description

This method creates a new sales quote.

Parameters

Parameter

Type

Description

salesQuote

SalesQuote

The sales quote 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 sales quote. The example first populates the required DocumentTypeKey, CustomerKey, and BatchKey properties. The sales quote uses a sales quote line to specify an item and quantity. The sales quote line requires the ItemKey, Quantity, QuantityToInvoice, and QuantityToOrder properties to be populated. The sales quote key and sales quote line key are not populated. The CreateSalesQuote operation automatically populates the empty sales quote key and sales quote line key with the next available quote number. All other sales quote properties are set to default values. The CreateSalesQuote operation saves the new sales quote.

 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;
			SalesDocumentTypeKey documentTypeKey;
			CustomerKey customerKey;
			BatchKey batchKey;
			ItemKey quoteItem;
			Quantity itemQuantity;
			Quantity quoteItemQuantity;
			SalesQuote salesQuote;
			SalesQuoteLine salesQuoteLine;
			Policy salesQuoteCreatePolicy;

			// 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 sales quote object
			salesQuote = new SalesQuote();

			// Create a sales document type key
			documentTypeKey = new SalesDocumentTypeKey();
			documentTypeKey.Type = SalesDocumentType.Quote;
			documentTypeKey.Id = "STDQTE";

			// Set the document type key of the sales quote object
			salesQuote.DocumentTypeKey = documentTypeKey;

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

			// Set the customer key property of the sales quote object
			salesQuote.CustomerKey = customerKey;

			// Create a batch key
			batchKey = new BatchKey();
			batchKey.Id = "SALES QUOTES";

			// Set the batch key property of the sales quote object
			salesQuote.BatchKey = batchKey;

			// Create a sales quote line to specify the quote items
			salesQuoteLine = new SalesQuoteLine();

			// Create an item key
			quoteItem = new ItemKey();
			quoteItem.Id = "128 SDRAM";

			// Set the item key property of the sales quote line object
			salesQuoteLine.ItemKey = quoteItem;

			// Create a quantity object
			itemQuantity = new Quantity();
			itemQuantity.Value = 0;

			// Initialize the quantity to invoice and quantity to order properties
			salesQuoteLine.QuantityToInvoice = itemQuantity;
			salesQuoteLine.QuantityToOrder = itemQuantity;

			// Create a quantity object
			quoteItemQuantity = new Quantity();
			quoteItemQuantity.Value = 2;

			// Set the quantity property of the sales quote line object
			salesQuoteLine.Quantity = quoteItemQuantity;

			// Create an array of sales quote lines
			// Initialize the array with the sales quote line object
			SalesQuoteLine[] quotes = { salesQuoteLine };

			// Add the sales quote line to the sales quote object
			salesQuote.Lines = quotes;

			// Get the create policy for sales quotes
			salesQuoteCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesQuote", context);

			// Create the sales quote
			wsDynamicsGP.CreateSalesQuote(salesQuote, context, salesQuoteCreatePolicy);
	}
}
}

 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;
			SalesDocumentTypeKey documentTypeKey;
			CustomerKey customerKey;
			BatchKey batchKey;
			ItemKey quoteItem;
			Quantity itemQuantity;
			Quantity quoteItemQuantity;
			SalesQuote salesQuote;
			SalesQuoteLine salesQuoteLine;
			Policy salesQuoteCreatePolicy;

			// 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 sales quote object
			salesQuote = new SalesQuote();

			// Create a sales document type key
			documentTypeKey = new SalesDocumentTypeKey();
			documentTypeKey.Type = SalesDocumentType.Quote;
			documentTypeKey.Id = "STDQTE";

			// Set the document type key of the sales quote object
			salesQuote.DocumentTypeKey = documentTypeKey;

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

			// Set the customer key property of the sales quote object
			salesQuote.CustomerKey = customerKey;

			// Create a batch key
			batchKey = new BatchKey();
			batchKey.Id = "SALES QUOTES";

			// Set the batch key property of the sales quote object
			salesQuote.BatchKey = batchKey;

			// Create a sales quote line to specify the quote items
			salesQuoteLine = new SalesQuoteLine();

			// Create an item key
			quoteItem = new ItemKey();
			quoteItem.Id = "128 SDRAM";

			// Set the item key property of the sales quote line object
			salesQuoteLine.ItemKey = quoteItem;

			// Create a quantity object
			itemQuantity = new Quantity();
			itemQuantity.Value = 0;

			// Initialize the quantity to invoice and quantity to order properties
			salesQuoteLine.QuantityToInvoice = itemQuantity;
			salesQuoteLine.QuantityToOrder = itemQuantity;

			// Create a quantity object
			quoteItemQuantity = new Quantity();
			quoteItemQuantity.Value = 2;

			// Set the quantity property of the sales quote line object
			salesQuoteLine.Quantity = quoteItemQuantity;

			// Create an array of sales quote lines
			// Initialize the array with the sales quote line object
			SalesQuoteLine[] quotes = { salesQuoteLine };

			// Add the sales quote line to the sales quote object
			salesQuote.Lines = quotes;

			// Get the create policy for sales quotes
			salesQuoteCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesQuote", context);

			// Create the sales quote
			wsDynamicsGP.CreateSalesQuote(salesQuote, context, salesQuoteCreatePolicy);

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


Documentation Feedback