Compensate Sales Orders That Change

Create a compensation pattern that makes an adjustment when a fulfillment task changes a sales order.

A compensation pattern is a rule you create on an orchestration process step. It specifies the adjustment to make when an order changes. Undo, Redo, Update, Cancel, and None are each an example of a compensation pattern.

For example, assume the compensation pattern for a Create Shipment step is Redo, and that the step calls the Cancel service and the Create service. If Order Management receives a change order that includes a new warehouse for the step, then it runs Cancel and Create again.

Assume you need a compensation pattern that pauses the orchestration process until compliance check finishes.

  • If compliance details change, then pause the orchestration process until compliance is done.

Here's the rule you will create.

Creating If statement

where

Code

Description

DooSeededOrchestrationRules

Dictionary that contains a set of predefined business rules for an orchestration process. You use it to store objects and their values.

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

DOOHeader

Object in DooSeededOrchestrationRules. It contains attributes for the sales order header and their values.

headerEFF

Extensible flexfield on the order header. For this example, assume you defined an extensible flexfield that stores details about the compliance check.

For details, see Overview of Setting Up Extensible Flexfields in Order Management.

DooSeededOrchestrationRules.FlexContexts

Establishes FlexContexts in the dictionary.

FlexContext

Object that stores the value for the extensible flexfield.

ComplianceDetails

Object that stores compliance details.

ComplianceInfo

Object that stores compliance information.

mRuleDecision.CompensationPattern

CompensationPattern is a property of object mRuleDecision. CompensationPattern stores the string UPDATE, which is the value that this rule uses to end the condition.

Here's a description of how the statement works.

Code

Description

header is a DooSeededOrchestrationRules.DOOHeader

Declare header as a temporary variable that stores the value from object DOOHeader of dictionary DooSeededOrchestrationRules.

Proceed to the next AND statement only after you declare header.

headerEFF is a DooSeededOrchestrationRules.FlexContext

Declare headerEFF as a temporary variable that stores the value from object FlexContext of DooSeededOrchestrationRules.

Proceed to the next AND statement only after you declare headerEFF.

headerEFF isn't null

Proceed to the next AND statement only if the extensible flexfield on the sales order header contains a value.

This set up uses headerEFF to store the value of the extensible flexfield that stores attribute Compliance Details on the order header. If the value of Compliance Details is empty, then it indicates compliance isn't required, compensation isn't required, and the orchestration process continues to the next orchestration process step.

header.flexContexts RL.contains headerEFF

Declare headerEFF into the rules language (RL) dictionary, and set the value of headerEFF to the value that flexContexts contains.

This condition makes sure you correctly declare the variable into the dictionary.

Proceed to the next AND statement only if RL contains headerEFF.

Do this test on each of your variables to make sure the declaration is correct. If you don't do the test, and if the declaration isn't correct, then the rule might fail in a subsequent step.

headerEFF.context isn't null

Make sure a context is defined for the order header. Proceed to the next AND statement only if context contains a value.

headerEFF.context equals ignore case "ComplianceDetails"

Get the context and segments for Compliance Details for this variable.

Proceed to the next AND statement only if context contains the string ComplianceDetails. Ignore case sensitivity when examining.

if context contains some other value, then it indicates that no other process requested a compliance check.

headerEFF.attributeChanged("_ComplianceInfo") is true

Make sure attribute ComplianceInfo of the extensible flexfield changed. You use attributeChanged to determine whether the value for ComplianceInfo is different in this revision.

This example includes a simple rule that processes only one line. Use an advanced rule to process more than one line. For details, see Overview of Using Business Rules With Order Management.

Summary of the Steps

  1. Create If statement.

  2. Create Then statement.

  3. Release pause task.

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

Create If Statement

You will create a statement.

  • If compliance details changed

Do it.

  1. Create the rule.

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

      • Offering: Order Management

      • Functional Area: Orders

      • Task: Manage Orchestration Process Definitions

    • 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.

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

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

    • In the Compensation Pattern dialog, click Add Rule > Properties, then set the values.

      Attribute

      Value

      Name

      Determine Whether Compliance Changed

      Description

      If compliance details changed, then pause the orchestration process until compliance is done.

      Effective Date

      Always

      Priority

      Medium

      Active

      Contains a check mark.

      Advanced Mode

      Contains a check mark.

      Tree Mode

      Doesn't contain a check mark.

  2. Declare variable header.

    • In the If area, in the window to the left of Is A, enter header.

    • Set the field to the right of Is A to DooSeededOrchestrationRules.DOOHeader.

  3. Declare variable headerEFF.

    • Click Add Pattern.

    • In the window to the left of Is A, enter headerEFF.

    • Set the field to the right of Is A to DooSeededOrchestrationRules.DOOHeader.

  4. Make sure headerEFF contains a value.

    • Click Add Test.

    • In the window to the left of Is, enter headerEFF.

    • Change Is to Isn't.

    • In the field to the right of Isn't, click Right Value > null > OK.

  5. Declare headerEFF into the rules language (RL) dictionary.

    • Click the down arrow located to the right of Right Value, then click Simple Test.

    • In the window to the left of Is, click Left Value, expand header, then click flexContexts > OK.

    • Change Is to RL.contains.

    • In the field to the right of RL.contains, click Right Value > headerEFF > OK.

  6. Make sure context contains a value.

    • Click Simple Test.

    • Near the window to the left of Is, click Left Value, expand headerEFF, then click context > OK.

    • Change Is to Isn't.

    • In the field to the right of Isn't, click Right Value > null > OK.

  7. Make sure context contains the string ComplianceDetails.

    • Click Simple Test.

    • Near the window to the left of Is, click Left Value, expand headerEFF, then click context > OK.

    • Change Is to Equals Ignore Case.

    • In the field to the right of Equals Ignore Case, click Right Value, enter "ComplianceDetails", then click OK.

      Make sure you include the double quotation ( " ) marks.

  8. Make sure attribute ComplianceInfo of the extensible flexfield changed.

    • Click Simple Test.

    • Near the window to the left of Is, click Left Value, expand headerEFF, and then click hasChanges.

    • In the window in the Condition Browser, notice the value.

      Insert "_ComplianceInfo" between the parentheses, then click OK. For example:

      headerEFF.attributeChanged("_ComplianceInfo")

    • In the window to the right of Is, enter the value.

Create Then Statement

Create the statement that pauses the orchestration process until compliance is done.

  1. In the Then area, click Add Action > Assign.

  2. Click Select a Target, then click header.mRuleDecision.compensationPattern.

  3. In the window to the right of the equal sign ( = ), enter "UPDATE".

    You must include the double quotation marks.

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

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

Pause the Task According to Date

You add this rule in the Pause Rule column on the same step where you added the compensation pattern.

Pause Task While Date Is Empty

Order Management sets the compliance completion date when compliance check is done. If the date is empty, then it indicates compliance check isn't done, and the rule doesn't release the pause task. For example:

  • If CompleteCompliancedate is empty, then compliance check isn't done. Assign a business event to indicate we must wait.

rule that pauses task while date is empty

Here's the code that the rule uses.

If header is a DooSeededOrchestrationRules.DOOHeader 
and if headerEFF is a DooSeededOrchestrationRules.FlexContext and 
  headerEFF isn't null and 
  header.flexContexts RL.contains headerEFF and 
  headerEFF.context isn't null and 
  headerEFF.context equals ignore case "ComplianceDetails" and 
  headerEFF.getFlexAttributeDateValue("_CompleteCompliancedate") is null 

then 
  assign header.sacResult.sacType = DooSeededOrchestrationRules.SacResult.SAC_TYPE_EVENT
  assign header.sacResult.eventName = "Awaiting Compliance Check Completion" 
  assign header.sacResult.reevaluateFlag = "N"

Pause for Future Date

You can create a rule that pauses until compliance completion date is later than order header date. For example:

  • If CompleteCompliancedate happens after order header date, then compliance check is done. Prepare to release the pause task.

To prepare to release the pause task, you set waitDateTime to the compliance date. For details about waitDateTime and sacResults, see Guidelines for Pausing Orchestration Processes.

rule that sets waitDateTime to the compliance date

Here's the code that the rule uses.

If header is a DooSeededOrchestrationRules.DOOHeader 
and if headerEFF is a DooSeededOrchestrationRules.FlexContext and 
  headerEFF isn't null and 
  header.flexContexts RL.contains headerEFF and 
  headerEFF.context isn't null and 
  headerEFF.context equals ignore case "ComplianceDetails" and 
  headerEFF.getFlexAttributeDateValue("_CompleteCompliancedate") isn't null 
  headerEFF.getFlexAttributeDateValue("_CompleteCompliancedate") more than header.current_date

then 
  assign header.sacResult.sacType = DooSeededOrchestrationRules.SacResult.SAC_TYPE_TIMER 
  assign header.sacResult.waitDateTime = headerEFF.getFlexAttributeDateValue("_CompleteCompliancedate")

Release Pause Task

Create a rule that releases the pause task. It doesn't reference the extensible flexfield you set up earlier in this topic. Instead, it uses rules.

  • Pause Rule for Null Date

  • Pause Rule for Future Date

It uses the values that these rules set for SacResult to determine when to release the pause task.

Here's the rule that releases the pause task.

rule that Releases Pause Task

Here's the code that this rule uses.

If header is a DooSeededOrchestrationRules.DOOHeader 

then 
  assign new DooSeededOrchestrationRules.sacResult SAC = new DooSeededOrchestrationRules.sacResult()
  assign header.sacResult = SAC
  assign header.sacResult.sacType = DooSeededOrchestrationRules.SacResult.SAC_TYPE_IMMEDIATE
  assign header.sacResult.reevaluateFlag = "N"

You add this rule in the Pause Rule column on the same step where you added the compensation pattern.