Another Example of Compensating Sales Orders That Change

Set up a compensation pattern that allows time to reschedule an orchestration process when a customer requests to change the ship date.

Here's the rule you will create.

  • If the requested ship date is less than or equal to the current date plus three days, then cancel and redo the Ship Product step.

Here's where you create the rule.

rule that Compensates Sales Orders That Change

Here's the code that the rule uses.

If
DooSeededOrchestrationRules.DOOFLine.requestShipDate same or less than CurrentDate.date.timeInMillis+3*24*60*60*1000

Then
assert new DooSeededOrchestrationRules.Result (resultObj."CANCEL_CREATE")

where

Code

Description

DooSeededOrchestrationRules

Dictionary you use to store objects and their values.

DOO means distributed order orchestration, which is term that Order Management used for order orchestration in earlier updates.

DOOFLine

Object in DooSeededOrchestrationRules. It contains fulfillment line attributes and their values.

requestShipDate

Fulfillment line attribute in DOOFLine.

time

Property of the toLocateString function. This function references the requestShipDate attribute.

CurrentDate.date.timeInMillis+3*24*60*60*1000

Equation that specifies to use the date that happens three days after the current date.

Result

Object in DooSeededOrchestrationRules that you use to store the result of the If statement.

resultObj

Property of the Result object.

It stores CANCEL_CREATE, which is the value that this rule uses to end the condition.

Summary of the Steps

  1. Create If statement.

  2. Create Then statement.

This topic uses example values. You might need different values, depending on your business requirements.

Create If Statement

You will create a statement.

  • If the requested ship date is less than or equal to the current date plus three days

Do it.

  1. In the Setup and Maintenance work area, go to the task.

    • Offering: Order Management

    • Functional Area: Orders

    • Task: Manage Orchestration Process Definitions

  2. On the Manage Orchestration Process Definitions page, locate the CallCustomerWhenLargeInvoice orchestration process, then click Actions > Edit.

    Learn how to create CallCustomerWhenLargeInvoice. For details, see Add Branches to Orchestration Processes.

  3. On the Edit Orchestration Process Definitions page, in the Process Details area, in the Step Definition list, click Change Management.

  4. In the Ship Item row, in the Compensation Pattern column, click Click for Rule.

  5. In the Compensation Pattern dialog, click Add Rule > Expand, then set the value.

    Attribute

    Value

    Name

    Rule to Compensate When Ship Date Changes

  6. In the If area, click Left Value, expand DOOSeededOrchestrationRules > DOOFline > requestShipDate, then click time > OK.

  7. In the Is list, click Is > Same or Less Than.

  8. Click Right Value.

  9. In the Condition Browser, expand CurrentDate > Date > Time, then click timeInMillis.

    Don't click OK.

  10. Near the top of the Condition Browser, in the window, after CurrentDate.date.timeInMillis, add +3*24*60*60*1000.

    Make sure the window now contains this value:

    CurrentDate.date.timeInMillis+3*24*60*60*1000

    The time function for most business rules work in milliseconds, so you must convert time to milliseconds. The calculation 3*24*60*60*1000 calculates the total number of milliseconds that three days contains, where.

    • 3 is the number of days.

    • 24 is the number of hours in one day.

    • 60 is the number of minutes in one hour.

    • 60 is the number of seconds in one minute.

    • 1000 is the number of milliseconds in one second.

  11. Click OK.

Create Then Statement

Create the statement that cancels, then restarts the Ship Product step so Order Management can reschedule the shipment.

  1. In the Then area, click Add Action > Assert New.

  2. Click Select a Target, then click DooSeededOrchestrationRules.Result.

  3. Click Edit Properties.

  4. In the Properties dialog, in the ResultObj row, enter the value.

    Attribute

    Value

    Value

    "CANCEL_CREATE"

    You must include the double quotation marks (").

  5. Click OK.

  6. Click Validate, make sure the Validation Log that displays doesn't contain any errors, then click Save.

  7. On the Edit Orchestration Process Definition page, click Save.