# Trigger

## Business Rule

{% hint style="warning" %}
There is no need for you to manually create a Trigger (Business Rule). If you have more than one, you will make duplicate updates.
{% endhint %}

{% hint style="info" %}
Unifi will automatically create a Trigger (Business Rule) for the Process being integrated *(if one doesn't already exist)* when you run 'Build' either on the Integration or Message once your Create Message is configured.
{% endhint %}

In **native ServiceNow**, navigate to **System Definition > Busines Rules**. Find and navigate to the automatically generated Business Rule.

{% hint style="info" %}
The format of the name will be '\[S] Unifi ' + \<Table Name> + ' trigger rule'.
{% endhint %}

![](/files/9ePwStaRM1bm5bogmmxE)

*The top section of your Business Rule record should look like this:*

![](/files/eAO116jcurFkB7zRO2ms)

## When to run Fields

*Your 'When to run' tab should look like this:*

![](/files/nW2YKKY1rMHuRZasJBEb)

## Advanced Fields

*The code in the script field should look like this:*

```javascript
(function executeRule(current, previous /*null when async*/) {
  x_snd_eb.ws_console.logExecute('Business rule: [S] Unifi ' + current.getTableName() + ' trigger rule', function () {
    x_snd_eb.ActivityLog.setDocument(current, 'sys_script');
    x_snd_eb.Message.processOutbound(current);
  });
})(current, previous);
```

*Your 'Advanced' tab should look like this:*

![](/files/yqMNvt7Iji5SFy7b1ljF)

We have confirmed the main elements are in place for our Integration to work. We are now ready to **Test** our **CreateIncident** Message.


---

# Agent Instructions: 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:

```
GET https://docs.sharelogic.com/unifi/4.2/integration-guides/outbound-incident-guide/create-scenario/trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
