> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aseeflow.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Business Rule Task

A Business Rule Task is used to synchronously execute one or more rules. It is also possible to call Java code or providing a work item for an external worker to complete asynchronously or invoking a logic which is implemented in form of webservices.

<img src="https://mintcdn.com/aseeflow/OpLRJy6TPnBLn55c/img/short-codes/bpmn-business-rule-task.png?fit=max&auto=format&n=OpLRJy6TPnBLn55c&q=85&s=7df2bf220040f4ab85b7f9f6effe37df" alt="" width="113" height="108" data-path="img/short-codes/bpmn-business-rule-task.png" />

## Using ASEE Flow DMN Engine

You can use the ASEE Flow DMN engine integration to evaluate a DMN decision. You have
to specify the decision key to evaluate as the `camunda:decisionRef` attribute. Additionally,
the `camunda:decisionRefBinding` specifies which version of the decision should be evaluated.
Valid values are:

* `deployment`, which evaluates the decision version which was deployed with the process
  version,
* `latest` which will always evaluate the latest decision version,
* `version` which allows you to specify a specific version to execute with the `camunda:decisionRefVersion` attribute, and
* `versionTag` which allows you to specify a specific version tag to execute with the `camunda:decisionRefVersionTag` attribute.

```xml theme={null}
<businessRuleTask id="businessRuleTask"
    camunda:decisionRef="myDecision"
    camunda:decisionRefBinding="version"
    camunda:decisionRefVersion="12" />
```

The `camunda:decisionRefBinding` attribute defaults to `latest`.

```xml theme={null}
<businessRuleTask id="businessRuleTask"
    camunda:decisionRef="myDecision" />
```

The attributes `camunda:decisionRef`, `camunda:decisionRefVersion`, and `camunda:decisionRefVersionTag` can be specified as
an expression which will be evaluated on execution of the task.

```xml theme={null}
<businessRuleTask id="businessRuleTask"
    camunda:decisionRef="${decisionKey}"
    camunda:decisionRefBinding="version"
    camunda:decisionRefVersion="${decisionVersion}" />
```

The output of the decision, also called decision result, is not saved as process variable automatically. It has to pass into a process variable by using a [predefined](/user-guide/process-engine/decisions/bpmn-cmmn#predefined-mapping-of-the-decision-result) or a [custom](/user-guide/process-engine/decisions/bpmn-cmmn#custom-mapping-to-process-variables) mapping of the decision result.

In case of a predefined mapping, the `camunda:mapDecisionResult` attribute references the mapper to use. The result of the mapping is saved in the variable which is specified by the `camunda:resultVariable` attribute. If no predefined mapper is set then the `resultList` mapper is used by default.

```xml theme={null}
<businessRuleTask id="businessRuleTask"
    camunda:decisionRef="myDecision"
    camunda:mapDecisionResult="singleEntry"
    camunda:resultVariable="result" />
```

See the [User Guide](/user-guide/process-engine/decisions/bpmn-cmmn#the-decision-result) for details about the mapping.

<Warning>
  **Name of the Result Variable**

  The result variable should not have the name `decisionResult`, as the decision result itself is saved in a variable with this name. Otherwise, an exception is thrown while saving the result variable.
</Warning>

## DecisionRef Tenant Id

When the Business Rule Task resolves the decision definition to be evaluated it must take multi tenancy into account.

### Default Tenant Resolution

By default, the tenant id of the calling process definition is used to evaluate the decision definition.
That is, if the calling process definition has no tenant id, then the Business Rule Task evaluates a decision definition using the provided key, binding and without a tenant id (tenant id = null).
If the calling process definition has a tenant id, a decision definition with the provided key and the same tenant id is evaluated.

Note that the tenant id of the calling process instance is not taken into account in the default behavior.

### Explicit Tenant Resolution

In some situations it may be useful to override this default behavior and specify the tenant id explicitly.

The `camunda:decisionRefTenantId` attribute allows to explicitly specify a tenant id:

```xml theme={null}
<businessRuleTask id="businessRuleTask" decisionRef="myDecision"
  camunda:decisionRefTenantId="TENANT_1">
</businessRuleTask>
```

If the tenant id is not known at design time, an expression can be used as well:

```xml theme={null}
<businessRuleTask id="businessRuleTask" decisionRef="myDecision"
  camunda:decisionRefTenantId="${ myBean.calculateTenantId(variable) }">
</businessRuleTask>
```

An expression also allows using the tenant id of the calling process instance instead of the calling process definition:

```xml theme={null}
<businessRuleTask id="businessRuleTask" decisionRef="myDecision"
  camunda:decisionRefTenantId="${ execution.tenantId }">
</businessRuleTask>
```

## Using a Custom Rule Engine

You can integrate with other rule engines. To do so, you have to plug in your
implementation of the rule task the same way as in a Service Task.

```xml theme={null}
<businessRuleTask id="businessRuleTask"
    camunda:delegateExpression="${MyRuleServiceDelegate}" />
```

## Using Delegate Code

Alternatively, a Business Rule Task can be implemented using Java Delegation just as a Service Task. For more
information on this please see the [Service Tasks](/reference/bpmn20/tasks/service-task) documentation.

## Implementing as an External Task

In addition to the above, a Business Rule Task can be implemented via the [External Task](/user-guide/process-engine/external-tasks) mechanism where an external system polls the process engine for work to do. See the section on [Service Tasks](/reference/bpmn20/tasks/service-task#external-tasks) for more information about how to configure an external task.

## ASEE Flow Extensions

<table class="table table-striped">
  <tr> <th>Attributes</th> <td> [camunda:asyncBefore](/reference/bpmn20/custom-extensions/extension-attributes#asyncbefore), [camunda:asyncAfter](/reference/bpmn20/custom-extensions/extension-attributes#asyncafter), [camunda:class](/reference/bpmn20/custom-extensions/extension-attributes#class), [camunda:decisionRef](/reference/bpmn20/custom-extensions/extension-attributes#decisionref), [camunda:decisionRefBinding](/reference/bpmn20/custom-extensions/extension-attributes#decisionrefbinding), [camunda:decisionRefTenantId](/reference/bpmn20/custom-extensions/extension-attributes#decisionreftenantid), [camunda:decisionRefVersion](/reference/bpmn20/custom-extensions/extension-attributes#decisionrefversion), [camunda:decisionRefVersionTag](/reference/bpmn20/custom-extensions/extension-attributes#decisionrefversiontag), [camunda:delegateExpression](/reference/bpmn20/custom-extensions/extension-attributes#delegateexpression), [camunda:exclusive](/reference/bpmn20/custom-extensions/extension-attributes#exclusive), [camunda:expression](/reference/bpmn20/custom-extensions/extension-attributes#expression), [camunda:jobPriority](/reference/bpmn20/custom-extensions/extension-attributes#jobpriority), [camunda:mapDecisionResult](/reference/bpmn20/custom-extensions/extension-attributes#mapdecisionresult), [camunda:resultVariable](/reference/bpmn20/custom-extensions/extension-attributes#resultvariable), [camunda:topic](/reference/bpmn20/custom-extensions/extension-attributes#topic), [camunda:type](/reference/bpmn20/custom-extensions/extension-attributes#type), [camunda:taskPriority](/reference/bpmn20/custom-extensions/extension-attributes#taskpriority) </td> </tr>
  <tr> <th>Extension Elements</th> <td> [camunda:failedJobRetryTimeCycle](/reference/bpmn20/custom-extensions/extension-elements#failedjobretrytimecycle), [camunda:field](/reference/bpmn20/custom-extensions/extension-elements#field), [camunda:connector](/reference/bpmn20/custom-extensions/extension-elements#connector), [camunda:inputOutput](/reference/bpmn20/custom-extensions/extension-elements#inputoutput) </td> </tr>
  <tr> <th>Constraints</th> <td> One of the attributes <code>camunda:class</code>, <code>camunda:delegateExpression</code>, <code>camunda:decisionRef</code>, <code>camunda:type</code> or <code>camunda:expression</code> is mandatory </td> </tr>
  <tr> <td /> <td> The attribute <code>camunda:resultVariable</code> can only be used in combination with the <code>camunda:decisionRef</code> or <code>camunda:expression</code> attribute </td> </tr>
  <tr> <td /> <td> The <code>camunda:exclusive</code> attribute is only evaluated if the attribute <code>camunda:asyncBefore</code> or <code>camunda:asyncAfter</code> is set to <code>true</code> </td> </tr>
  <tr> <td /> <td> The attribute <code>camunda:topic</code> can only be used when the <code>camunda:type</code> attribute is set to <code>external</code>. </td> </tr>
  <tr> <td /> <td> The attribute <code>camunda:taskPriority</code> can only be used when the <code>camunda:type</code> attribute is set to <code>external</code>. </td> </tr>
</table>

## Additional Resources

* [Decisions](/user-guide/process-engine/decisions)
* [Service Tasks](/reference/bpmn20/tasks/service-task)
* [Tasks](https://camunda.com/bpmn/reference/#activities-task) in the [BPMN 2.0 Modeling Reference](https://camunda.com/bpmn/reference/)
* [Demo using Drools on the Business Rule Task](https://github.com/camunda/camunda-consulting/tree/master/one-time-examples/order-confirmation-rules)
