This API creates a partial order from a quote or agreement. 

For detailed information on partial orders, refer to the Order Management for Users.

API Details

APISignature
CreateOrderRequestwebService static CPQApi.CPQ.CreateOrderResponseDOCreateOrderRequest(CPQApi.CPQ.CreateOrderRequestDO)

Parameters

Name

Type

Description

request

CPQApi.CPQ.CreateOrderRequestDO

     The request data object.

Request Data Object - CPQApi.CPQ.CreateOrderRequestDO

Field

Type

Required?

Description

CustomFields

List<String>

No

List of custom fields on orderSO

OrderInput

Apttus_Config2__Order__c

Yes

OrderSO

OrderItems

List<Apttus_CPQApi.CPQ.SelectedProductDO>

No

List of order items

OrderItemSource

String

Yes

Source of order items

Properties

List<Apttus_Config2.Property>

No

List of properties for cart created for order

Request Data Object - CPQApi.CPQ.SelectedProductDO

Field

Type

Required?

Description

AttributeValues

List<Apttus_Config2__ProductAttributeValue__c>

No

The product attribute value for the product

Comments

String

No

Comments

CopyBundleConfigurationFromSource

Boolean

No

For bundles, to copy bundle configuration

CustomData

Apttus_Config2__LineItem__c

No

Custom data line item

CustomFields

List<String>

No

List of custom fields

EndDate

Date

No

End date

ProductId

Id

No

Product Id

Quantity

Decimal

No

Quantity

RelatedLineItems

List<Apttus_Config2__RelatedLineItem__c>

No

List of related line items

SellingTerm

Decimal

No

Selling term

SourceFields

List<String>

No

List of source custom fields to be copied

SourceId

Id

No

Id of a source item

StartDate

Date

No

Start Date

Code Sample

The following sample uses an explicit product definition for order items while creating partial order from quote/agreement.

Apttus_CPQApi.CPQ.CreateOrderRequestDO request = new Apttus_CPQApi.CPQ.CreateOrderRequestDO();

// order item source
request.OrderItemSource = Apttus_CPQApi.CPQ.ITEMSOURCE_QUOTE_LINEITEM;

// create order input
Apttus_Config2__Order__c inputSO = new Apttus_Config2__Order__c();

inputSO.Apttus_Config2__SoldToAccountId__c = quote.Apttus_Proposal__Account__c;
inputSO.Apttus_Config2__PriceListId__c = quote.Apttus_QPConfig__PriceListId__c;
inputSO.Apttus_Config2__PricingDate__c = Datetime.now();
inputSO.Apttus_Config2__OrderDate__c = Datetime.now();
inputSO.Apttus_Config2__OrderStartDate__c = Date.today();
inputSO.Apttus_Config2__OrderEndDate__c = Date.today().addMonths(12);
inputSO.Apttus_QPConfig__ProposalId__c = quote.Id;
InputSO.Apttus_Config2__Source__c = 'Quote';

request.OrderInput = inputSO;

// add order items
Apttus_Proposal__Proposal_Line_Item__c quoteLine = [SELECT 
                                                    Id,
                                                    Name,
                                                    Apttus_Proposal__Product__c
                                                    FROM Apttus_Proposal__Proposal_Line_Item__c
                                                    WHERE Id =: quoteLineId];

// selected item
Apttus_CPQApi.CPQ.SelectedProductDO productDO = new Apttus_CPQApi.CPQ.SelectedProductDO(); 
productDO.Comments = 'Test Create Order API';
productDO.StartDate = Date.today();
productDO.EndDate = Date.today().addMonths(12);
productDO.SellingTerm = 12;DL
productDO.Quantity = 2;
productDO.ProductId = quoteLine.Apttus_Proposal__Product__c;
productDO.SourceId = quoteLine.Id;
productDO.CopyBundleConfigurationFromSource = true;

request.OrderItems.add(productDO);

// create order
Apttus_CPQApi.CPQ.CreateOrderResponseDO result = Apttus_CPQApi.CPQWebService.createOrder(request);
system.debug('result='+result);

CODE


 Code Sample

This sample uses an explicit product definition for order items while creating a partial order from a quote or an agreement.

Apttus_CPQApi.CPQ.CreateOrderRequestDO request
= new Apttus_CPQApi.CPQ.CreateOrderRequestDO();

// order item source

request.OrderItemSource = Apttus_CPQApi.CPQ.ITEMSOURCE_QUOTE_LINEITEM;

// create order input

Apttus_Config2__Order__c inputSO = new Apttus_Config2__Order__c();

inputSO.Apttus_Config2__SoldToAccountId__c = '0014C00000F9Zz3';

inputSO.Apttus_Config2__PriceListId__c = 'a174C0000001MQ1';

inputSO.Apttus_Config2__PricingDate__c = Datetime.now();

inputSO.Apttus_Config2__OrderDate__c = Datetime.now();

inputSO.Apttus_Config2__OrderStartDate__c = Date.today();

inputSO.Apttus_Config2__OrderEndDate__c = Date.today().addMonths(12);


// add custom fields to orderSO (optional)

inputSO.put('Apttus_QPConfig__ProposalId__c','a0Y4C0000021Cm5');

request.OrderInput = inputSO;

request.CustomFields.add('Apttus_QPConfig__ProposalId__c');

// add order items (optional)


// selected item


Apttus_CPQApi.CPQ.SelectedProductDO productDO
= new Apttus_CPQApi.CPQ.SelectedProductDO();

productDO.Comments = 'Test Create Order API';

productDO.CopyBundleConfigurationFromSource = false;

productDO.StartDate = Date.today();

productDO.EndDate = Date.today().addMonths(12);

productDO.SellingTerm = 12;

productDO.Quantity = 1;

//productDO.ProductId = '01t4C000001pB1J';


// add attributes to the selected product (optional)


Apttus_Config2__ProductAttributeValue__c
attVal = new Apttus_Config2__ProductAttributeValue__c();

attVal.APTS_TestAttColor__c = 'Black';

productDO.AttributeValues.add(attVal);


// add related line items to selected product (optional)


Apttus_Config2__RelatedLineItem__c
lineItem = new Apttus_Config2__RelatedLineItem__c();


lineItem.Apttus_Config2__RelationType__c = 'Wallet';


productDO.RelatedLineItems.add(lineItem);


// source id and the explicit product definition are mutually exclusive


productDO.SourceId = 'a0W4C000001MRRF';


request.OrderItems.add(productDO);


// add order properties to use contract pricing (optional)


// order properties (optional)


// request.Properties.add(new
Apttus_Config2.Property('useAdvancedApproval' 'false'));


// request.Properties.add(new Apttus_Config2.Property('useDealOptimizer'
'false'));


// request.Properties.add(new Apttus_Config2.Property('retId',
'a0Y4C0000021Cm5'));


request.Properties.add(new Apttus_Config2.Property('cntrNbr_1', 'Q-00004442'));


// Q-00004442 is the contract number in this example (Contract Number
field on PriceList object)


// create order api call


Apttus_CPQApi.CPQ.CreateOrderResponseDO result
= Apttus_CPQApi.CPQWebService.createOrder(request);
CODE