# How to set up business rules to trigger other business rules

## When is it useful for a business rule to trigger other business rules?

There are several reasons you might want a business rule to trigger other business rules, also referred to as subrules.

Reasons why you might want to make a sub rule:

* You want to reuse parts of a rule so the same logic is used in multiple places.
* You want to take actions on an entity that is related to the triggering entity.
* You want actions to be taken asynchronously.

## Setting up the sub rule

Start by creating your sub rule and choosing an action trigger.

<figure><img src="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2Fob5Yj4clEPpdEDCDgtNy%2Fimage.png?alt=media&#x26;token=574c1445-9d1b-48a6-895e-2dd48d896816" alt=""><figcaption><p>Select action trigger</p></figcaption></figure>

When choosing a [trigger](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details) you will need to choose the type of entity the rule needs to act on.\
\
After you have picked the [trigger](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details), setup the rest of the rule as normal. (Remember to click "Create Business rule" to save the rule).

## Setting up the business rule that triggers your sub rule

Open the business rule you want to [trigger](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details) the sub rule.

Add an [action](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/actions/action-details) and choose "Trigger sub rule". Choose the same entity that you chose on your sub rule for "Entities to execute for" and select the sub rule for "Rule to execute".

{% hint style="warning" %}
**Note** If you choose a different entity to what triggered the original rule, it will run the rule for all related entities which might make the sub rule run more than once.
{% endhint %}

If you wish to execute the rule asynchronously toggle the "Execute async" check.

{% hint style="success" %}
**Note** If your sub rule applies to more than one entity it is highly recommended that you run it asynchronously to optimize the execution time.
{% endhint %}

<div><figure><img src="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2Fr4lzMY3bssJteFlqekN2%2FSk%C3%A6rmbillede%202025-09-02%20143845.png?alt=media&#x26;token=13485d72-9243-47ec-9c83-ce199c190f61" alt=""><figcaption><p>Select action</p></figcaption></figure> <figure><img src="https://2141378775-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuUonpFWM7AJ0xVVXV1tr%2Fuploads%2F4a4E6TJ5xPYb5CZ1H8Fy%2FSk%C3%A6rmbillede%202025-09-02%20144138.png?alt=media&#x26;token=9baf6de8-f8e5-4ca4-ac3a-c5f2f3d737aa" alt=""><figcaption><p>Configure action</p></figcaption></figure></div>

## Pitfalls when using sub rules

When using sub rules there are some pitfalls you should be aware of:

* Your sub rule can [trigger](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details) other rules either directly or by taking an [action](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/actions/action-details) that [triggers](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details) a rule. This can cause a loop where rules [trigger](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details) themselves. To avoid this Struct PIM only allows a rule to [trigger](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/triggers/trigger-details) 10 times per original [action](https://docs.struct.com/reference/settings/data-governance/business-rules/business-rule-details/actions/action-details).&#x20;
* Changing a sub rule will change behavior wherever it is used, so be cautious of all the places a rule is used before changing it.
