Administering : Managing business rules and expressions : Business rule definition examples : SetChoice example: Compare attributes
  
SetChoice example: Compare attributes
In this example, the SetChoice business rule is used to analyze whether the cost of a project is within or over the budget.
The Project module contains two Integer attributes, Budget Cost and Actual Cost, and a Choice attribute named Budget. The Budget attribute contains two items: Within Budget and Over Budget. To model the relationship between the budgeted and actual costs, use the SetChoice business rule and an expression to update the Budget attribute:
1 Add a Choice attribute that has two items: Within Budget and Over Budget.
2 Add an Integer attribute named “Cost Evaluation”. In that attribute, enter the following expression:
='Actual Cost' >= 'Budget Cost' ? 1 : 2
The settings of the Cost Evaluation attribute
This expression indicates that if the Actual Cost is greater than or equal to the Budget Cost, the value is 1. Otherwise, the value is 2.
3 Add a Text attribute named SetChoice to be the business container attribute, as shown in the following image. In that attribute, enter the following business rule:
=SetChoice("328","18","false","18_2","19_1",'Cost Evaluation')
The business rule indicates that the Budget attribute (ID 328), must be set to the Within Budget item (ID 18), except when the value in Cost Evaluation is 1. In that case, the Budget attribute must be set to the Over Budget item (ID 19).
The settings for the SetChoice attribute
The actual cost exceeds the budgeted cost, and the SetChoice business rule updates the Budget attribute to Over Budget. You can display all the projects that exceed budget costs by creating a view or a filter based on the Budget attribute.
The Budget attribute for the project indicates that it is Over Budget
Go up to
Business rule definition examples