> For the complete documentation index, see [llms.txt](https://docs.struct.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.struct.com/pim3/tutorials/helpful-guides/how-to-use-business-rules/how-to-set-up-business-rules-to-trigger-other-business-rules.md).

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

<div><figure><img src="/files/YT9QrVcnUb7dsESOvnKt" alt="" width="563"><figcaption><p>Business rules setup page</p></figcaption></figure> <figure><img src="/files/6oNdmww5KRhr1qfGBlZv" alt="" width="375"><figcaption><p>Select trigger</p></figcaption></figure></div>

When choosing a [trigger](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md) you will need to choose the type of entity the rule needs to act on.\
\
After you have picked the [trigger](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md), 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](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md) the sub rule.

Add an [action](/pim3/reference/product-model-setup/business-rules/business-rule-details/actions/action-details.md) 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="/files/GhoD5Q4NG01651xF3sns" alt="" width="375"><figcaption><p>Select action</p></figcaption></figure> <figure><img src="/files/GDteu5JDqZDe6fQj7bC1" alt="" width="375"><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](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md) other rules either directly or by taking an [action](/pim3/reference/product-model-setup/business-rules/business-rule-details/actions/action-details.md) that [triggers](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md) a rule. This can cause a loop where rules [trigger](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md) themselves. To avoid this Struct PIM only allows a rule to [trigger](/pim3/reference/product-model-setup/business-rules/business-rule-details/triggers/trigger-details.md) 10 times per original [action](/pim3/reference/product-model-setup/business-rules/business-rule-details/actions/action-details.md).&#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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.struct.com/pim3/tutorials/helpful-guides/how-to-use-business-rules/how-to-set-up-business-rules-to-trigger-other-business-rules.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
