Skip to main content

Creating decision trees

Pega Community logo

Note: The following content, referenced from Pega Community, is included here to help you better achieve the module learning objectives.

Calculate a value from a set of properties or conditions where true comparisons can lead to additional comparisons, organized and displayed as a tree structure, by creating a decision tree. For example, you can create a condition that checks whether the location of a job candidate is equal to a specific city. If the condition is true, your application evaluates additional conditions, such as work experience and education.

  1. In the header of Dev Studio, click Create Decision Decision Tree .

  2. In the Label field, enter a name that describes the purpose of the decision tree.

  3. In the Apply to field, select the class in which you want to create the decision tree.

  4. Click Create and open.

  5. Select the branch to display the columns.

  6. Define a condition and a result:

    Choices Actions
    Define a single condition
    1. In the first field, enter a property or a value.

    2. In the drop-down list, select a comparator.

    3. In the next field, enter a property or value that your application compares against the first property or value.

    4. In the then list, select return.

    5. In the last field, enter a property or value result that you want your application to return.

      For example: If you want a reporting manager to review any job application from candidates with > than 10 years of work experience, you can create the following condition and result: if .WorkExperience > 10 then return Work Manager.
    Define nested conditions
    1. In the first field, enter a property or a value.

    2. In the drop-down list, select a comparator.

    3. In the next field, enter a property or value that your application compares against the first property or value.

    4. In the then list, select continue.

    5. Select the next branch to display the columns.

    6. Define a nested condition by providing a property or value, a comparator, and a result.

      For example: If the work experience of a job candidate is greater than 10 years, then your application checks whether the candidate has a master's degree.
  7. Optional:

    To create complex conditions, click Add row, and then repeat step 6.

  8. In the otherwise section, define the behavior of your application if all of the conditions evaluate as false:

    Choices Actions
    Return a value
    1. From the list, select Return.

    2. In the Default return value field, enter a value that you want to use.

    3. Optional:

      To configure your application to perform an action, click Take actions, click Add a row, and then define the action.

      For example: Change a case status by defining the following action: Set pyUpdateCaseStatus equal to Resolved-Rejected.
    Perform an action
    1. From the list, select Perform action.

    2. Click Actions.

    3. Click Add a row.

    4. Define an action by setting a value for the action property.

      For example: Change a case status by defining the following action: Set pyUpdateCaseStatus equal to Resolved-Rejected.
  9. Optional:

    To ensure that your application can process the tree, check the tree for conflicts by clicking Show conflicts on the toolbar.

    For example: If one row checks whether the work experience is greater than 5 years, and the second row checks whether the work experience is greater than 3 years, the second row never evaluates to true because the first row includes the second row condition.
    Note: A warning icon appears in rows that are unreachable or empty.
  10. Optional:

    To increase the possibility of reaching a return value, test for completeness of the tree by clicking Show completeness on the toolbar.

    Note: The system automatically adds suggested rows of the decision tree that cover additional cases.
  11. Click Save.

  • About Decision Trees

    Use a decision tree to record if .. then logic that calculates a value from a set of test conditions organized as a tree structure on the Decision tab, with the 'base' of the tree at the left.

  • Viewing rule history

    You can view the saved history of a rule to see when it was changed and by whom. You can also compare the current version with a previous version or restore a previous version of a rule for testing purposes, or if the current version is faulty.

  • Viewing generated Java code of Access When rules
If you are having problems with your training, please review the Pega Academy Support FAQs.

Thank you for your feedback.

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice