How to set up business rules to trigger other business rules
Last updated
Last updated
Sometimes you might want to have a business rule trigger another business rule. You can do this by setting up a rule with an "action trigger" that can be triggered with the "Trigger sub rule" action.
Some reasons why you might want to make a sub rule include: You want to reuse parts of a rule so the same logic gets used multiple places. You want to take actions on an entity that is related to the triggering entity. You want actions to be taken asynchronously.
To start with you should set up your sub rule and choose an action trigger.
When choosing a trigger you will need to choose what type of entity the rule needs to act on. After you have picked the trigger set up the rest of the rule as normal. (Remember to click Create Business rule to save the rule).
In your original rule set up a trigger sub rule action. When setting up this action you should chose the same "entities to execute for" as on your sub rules trigger. Note that if you choose a different entity that what triggered the original rule it will run the rule for related entities and this might make the sub rule run more than once. Then you should pick you sub rule in the "rule to execute". Then you should choose whether the sub rule should be run asynchronously. If your sub rule applies to more than one entity its highly recommended that you run it async, to optimize the execution time.
When using sub rules there are some pitfalls that you should be aware of:
Your sub rule can trigger other rules either directly or by taking an action that triggers a rule. This can cause a loop where rules trigger themself. To avoid this Struct pim only allows a rule to trigger 10 time pr original action.
Changing a sub rule will change behavior where ever it is used so make sure you are aware of all the places a rule is used before changing it.