PDF
Download PDF
Download page Creating Orders from PO.
Creating Orders from PO
This API creates a sales order from a Customer Purchase Order: single order, multiple order using split criteria, or partial order.
You must enable the Split Group Properties field on the PO item in order to consume this functionality. Refer to the Order Management for Administrators for steps.
API Details
API | Signature |
---|---|
createOrderForPO | webService static Apttus_CPQApi.CPQ.CreateOrderForPOResponseDO createOrderForPO(Apttus_CPQApi.CPQ.CreateOrderForPORequestDO) |
Parameter 1: Create Order for Customer Purchase Order Data Object | ||
---|---|---|
Name | Type | Description |
request | Apttus_CPQApi.CPQ.CreateOrderForPORequestDO | The request data object. |
Request Data Object - CreateOrderForPORequestDO | ||
---|---|---|
Field | Type | Description |
orderInputSO | Standard Object | To create the order inputs. |
PurchaseOrderId | ID | To create a single order. |
SplitGroupFields | List<String> | To group by orders |
Request Standard Object - orderInputSO | |||
---|---|---|---|
Field | Type | Required? | Description |
SoldToAccountId | ID | Yes | The id of the Account to which the order is placed. |
PriceListId | ID | Yes | The id of the PriceList to be associated with the order. |
PricingDate | Datetime | No | Date and time associated with the order and represent the date when the order will be priced. |
OrderDate | Datetime | No | Date and time when the order is created. |
OrderStartDate | Datetime | No | Date and time when the order fulfillment starts. |
OrderEndDate | Datetime | No | Date and time when the order fulfillment ends. |
useAdvancedApproval | Boolean | No | Whether to use advanced approval. The default value is False. |
useDealOptimizer | Boolean | No | Whether to use the Deal Optimizer. The default value is False. |
Parameter 2: Create Selected Purchase Order Item Data Object | ||
---|---|---|
Name | Type | Description |
request | Apttus_CPQApi.CPQ.SelectedPOItemDO poItemDO | The request data object. |
Request Data Object - poItemDO (Required for partial order only) | |||
---|---|---|---|
Field | Type | Required? | Description |
POItemId | ID | Yes | Customer PO item number. |
ProductId | ID | Yes | Customer Product item number. |
Quantity | Integer | Yes | Quantity of the order. |
StartDate | Datetime | No | Date and time when the PO fulfillment starts. |
EndDate | Datetime | No | Date and time when the PO fulfillment ends. |
Selling Term | Integer | No | Duration of the customer PO. |
Comments | Text | No | Any notes. |
SourceId | ID | Yes | Source ID of the order. For example, Quote, Contract, or Agreement ID. |
Comments | Text | No | Comments about the agreement. |
ContractNumbers | Text | No | Contract number from the agreement. |
API Response
Response Data Object - Apttus_CPQApi.CPQ.CreateOrderForPOResponseDO | ||
---|---|---|
Name | Type | Description |
OrderId | ID | Order number which is created for customer PO. |
Code Sample
String ACCOUNT_NAME = 'RY_Account_002';
String PRICELIST_NAME = 'RY_PriceList';
Integer SELLING_TERM = 12;
Id CUSTOMER_PO_ID = 'a440R0000002Tif';
String SPLIT_ORDER_FIELD = 'RY_GroupingTest__c';
Id PO_ITEM_ID = 'a430R000000O2tC';
Id SOURCE_ITEM_ID = 'a0W0R000000JT9F';
Account myAccount = [SELECT Id FROM Account WHERE Name =: ACCOUNT_NAME];
Apttus_Config2__PriceList__c myPriceList = [SELECT Id FROM Apttus_Config2__PriceList__c WHERE Name =: PRICELIST_NAME];
Apttus_Config2__CustomerPOItem__c poItem = [SELECT Id, RY_GroupingTest__c, Apttus_Config2__ProductId__c, Apttus_Config2__Quantity__c, Apttus_Config2__StartDate__c, Apttus_Config2__EndDate__c FROM Apttus_Config2__CustomerPOItem__c WHERE Apttus_Config2__PurchaseOrderId__c =: CUSTOMER_PO_ID AND Id =: PO_ITEM_ID LIMIT 1];
/*
Create Order for Customer Purchase Order Data Object */
Apttus_CPQApi.CPQ.CreateOrderForPORequestDO request = new Apttus_CPQApi.CPQ.CreateOrderForPORequestDO();
// Create the Order Input
Apttus_Config2__Order__c orderInputSO = new Apttus_Config2__Order__c();
orderInputSO.Apttus_Config2__SoldToAccountId__c = myAccount.Id;
orderInputSO.Apttus_Config2__PriceListId__c = myPriceList.Id;
orderInputSO.Apttus_Config2__PricingDate__c = Datetime.now();
orderInputSO.Apttus_Config2__OrderDate__c = Datetime.now();
orderInputSO.Apttus_Config2__OrderStartDate__c = Date.today();
orderInputSO.Apttus_Config2__OrderEndDate__c = Date.today().addMonths(SELLING_TERM);
request.OrderInput = orderInputSO;
// Add Order Properties (Optional)
request.Properties.add(new Apttus_Config2.Property('useAdvancedApproval', 'false'));
request.Properties.add(new Apttus_Config2.Property('useDealOptimizer', 'false'));
// Assign the Customer Purchase Order (For single order)
request.PurchaseOrderId = CUSTOMER_PO_ID;
// Add Order Items (Optional)
// Selecting Items
// Create Selected Purchase Order Item Data Object
Apttus_CPQApi.CPQ.SelectedPOItemDO poItemDO = new Apttus_CPQApi.CPQ.SelectedPOItemDO(); (For partial order)
//webService Apttus_Config2__LineItem__c CustomData
//webService List CustomFields
poItemDO.POItemId = poItem.Id;
poItemDO.ProductId = poItem.Apttus_Config2__ProductId__c;
poItemDO.Quantity = poItem.Apttus_Config2__Quantity__c;
poItemDO.StartDate = poItem.Apttus_Config2__StartDate__c;
poItemDO.EndDate = poItem.Apttus_Config2__EndDate__c;
poItemDO.SellingTerm = Apttus_Config2.CPQWebService.computeTerm(poItemDO.StartDate,poItemDO.EndDate,'Monthly');
poItemDO.Comments = 'Purchase order item test';
// Set Additional Parameters From Source Line Item
poItemDO.SourceId = SOURCE_ITEM_ID;
poItemDO.SourceFields.add('Apttus_QPConfig__Comments__c');
poItemDO.SourceFields.add('Apttus_QPConfig__ContractNumbers__c');
request.OrderItems.add(poItemDO);
// Split Order Criteria
//request.SplitGroupFields.add(SPLIT_ORDER_FIELD); (For group by orders)
// Create the Order(s)
Apttus_CPQApi.CPQ.CreateOrderForPOResponseDO result = Apttus_CPQApi.CPQWebService.createOrderForPO(request);
system.debug('Order Id = ' + result.OrderId);
CODE