AmendOrder()

Make In-Flight order changes. Use this API to make the following changes to Order Line Items (OLI):

  • Change the start date or end date of subscription on one or more order line items that are in "Pending", "In Fulfillment", or "Partially Fulfilled" status. 
  • Make subscription date changes on the standalone item, bundles, and multiple charge line items.
  • Cancel order line items in "Pending," "In Fulfillment," or "Partially Fulfilled" status. This changes their status to "Pending Cancellation."
  • Override the "Base Price" field.
  • Change the Quantity.
  • Change the Selling Term, Selling Frequency, and/or Selling Unit-of-Measure (Selling Uom).
  • Modify Contract Numbers
  • Change the Adjustment Type/Adjustment Amount.

The following changes to an order occur after it has been amended:

  • The change in subscription start and/or end date recalculates the price for the line item or bundle after the changes are applied.
  • The changes to the order line items are also reflected in the corresponding assets.
  • Assets are only created on activation of the order line item.
  • Creates a new version of the order to make and track changes and has reference to the previous version. The previous version of the order and order line items are "Superseded", once the work-in-progress (In Amendment) changes are confirmed on "Accept" of the "In Amendment" order.
  • Cancelled order line items are assigned the "Pending Cancellation" status. The order must be accepted to confirm cancellation.
  • Order line items that are added from catalog (line status = "New") or created through ABO actions (line status In "Amended", "Cancelled", "Renewed", "Upgraded") can be amended.
  • Any order configured directly or generated from quote or eCommerce can be amended. 

For more information on amending an order, refer to the topic "Managing In-Flight Changes and Cancellation" in the Order Management on Salesforce User Guide.

API Details

Parameters

Name

Type

Description

request

Apttus_Config2.CPQStruct.AmendOrderRequestDO

The request data object.

Request Data Object - Apttus_Config2.CPQStruct.AmendOrderRequestDO

Field

Type

Required?

Description

OrderId

ID

Yes

Reference to the order. Order Id can be any one of the following:

  • Order in "Pending, In Fulfillment, Partially Fulfilled" status that requires amendment.
  • Order in "In Amendment" status for which additional line item changes are required.

OrderItems

List

NoList of order line items and changes to make:
  • Order line item id: Reference to the order line item
  • Start Date: New Start date for the order line item. Not needed for the order line item if the termination date for existing subscription needs to be changed. 
  • End Date: New end date for the order line item. If the termination date needs to be changed on existing subscription then just specify the new end date. 
  • Contract Numbers: If the termination date needs to be changed on existing subscription then set this value to null or same as End Date.
  • Base Price: New base price for the order line item.
  • Quantity: New quantity for the order line item (see sample below).
  • Selling Term / Selling Frequency: The new Selling Term or Selling Frequency for an order line item. 
  • Selling Unit-of-Measure: The new Selling Uom for an order line item.
  • Adjustment Type / Adjustment Amount: The new price Adjustment Type and/or Adjustment amount for the order line item.

API Response

Response Data Object - CPQStruct.AmendOrderResponeDO

Field

Type

Description

AmendedOrderItems

List

List of amended order items

AmendOrderSOStandard Data ObjectThe fields of the AmendOrder Object.

Code Sample

The following code sample enables you to amend an order for a valid order with an Order Id.

Id orderid = 'a2n4C0000007NFpQAM'; 
List<Apttus_Config2__OrderLineItem__c> lineitemlist = 

[ Select Id, Name, Apttus_Config2__StartDate__c,Apttus_Config2__EndDate__c from Apttus_Config2__OrderLineItem__c 
where
Id IN ('a2k4C000000D7yt', 'a2k4C000000D7yu', 'a2k4C000000D7yv','a2k4C000000D7yw')];
              
              lineitemlist[0].Apttus_Config2__StartDate__c=date.newInstance(2017, 10, 01);
              lineitemlist[0].Apttus_Config2__EndDate__c=date.newInstance(2018, 8, 31);
              /*****For line item, where cancellation date needs to be changed, provide the end date and set Contract Numbers field to null*******/ 
               lineitemlist[1].Apttus_Config2__EndDate__c=date.newInstance(2018, 9, 30);
              lineitemlist[1].Apttus_Config2__ContractNumbers__c=null;
              
               /****to change the quantity of line item ****/
              lineitemlist[2].Apttus_Config2__Quantity__c=3;
              
               /***Canceling the line item by changing the status of line item to Pending cancellation ****/
              lineitemlist[3].Apttus_Config2__Status__c='Pending Cancellation';
              
               Apttus_Config2.CPQStruct.AmendOrderRequestDO request = new Apttus_Config2.CPQStruct.AmendOrderRequestDO(); 
               request.OrderId = orderid; request.OrderItems = lineitemlist; 
               Apttus_Config2.CPQStruct.AmendOrderResponseDO Amend_response =  Apttus_Config2.OrderWebService.amendOrder (request);
              system.debug('OrderID_Of_New_Version -'+Amend_response.AmendOrderSO.id); /**This ID should be passed While Processing Undo Amend request **/
              
               
               /******* Accepting new order *********************/ 
               Apttus_Config2.CPQStruct.AcceptOrderRequestDO request1 = new Apttus_Config2.CPQStruct.AcceptOrderRequestDO();
              
               
               /*Apttus_Config2__Order__c newOrder = [ Select Id, Name, Apttus_Config2__ActivatedDate__c from Apttus_Config2__Order__c 
               where Apttus_Config2__PreviousVersion__c = :orderid]; 
               
               request1.OrderId = newOrder.Id; /** you can either use id for above query **/
              OR */
              request1.OrderId=Amend_response.AmendOrderSO.id // you can use the id of new orderversion from above response 
               
               
              /* *********** updating ready for activation date on the order or order line items for auto activation of the amended lines ******/
              
               //newOrder.Apttus_Config2__ActivatedDate__c = system.now();
              
              List<Apttus_Config2__OrderLineItem__c> lineitemlist1 = 
               
               [Select Id, Name, Apttus_Config2__ActivatedDate__c from Apttus_Config2__OrderLineItem__c where Apttus_Config2__OrderId__c = :
              .Id and Apttus_Config2__Status__c = 'In Amendment']; 
               lineitemlist1[0].Apttus_Config2__ActivatedDate__c = system.now(); 
               lineitemlist1[1].Apttus_Config2__ActivatedDate__c = system.now();
              
              update lineitemlist1;
              
              Apttus_Config2.CPQStruct.AcceptOrderResponseDO response = Apttus_Config2.OrderWebService.acceptOrder(request1);
CODE