---
description: >-
  We will configure an inbound create message to process the data returned from
  the poll and create a new target record.
---

# CreateIncidentInbound Message

## New Message Modal

Click the **'Messages' icon**, then **New**.

The fields to be configured for the CreateIncidentInbound New Message modal are as follows:

|  #  | Field        | Description                                                         | Value                   |
| :-: | ------------ | ------------------------------------------------------------------- | ----------------------- |
|  1  | Message name | The message name that is unique for this integration.               | 'CreateIncidentInbound' |
|  2  | Type         | The primary purpose of the message.                                 | 'Create'                |
|  3  | Direction    | The direction(s) this message is configured to support.             | 'Inbound'               |
|  4  | Description  | The description for this message and the requirement it is meeting. | \<Your description>     |

_Your CreateIncidentInbound New Message modal should look like this:_

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLWta_N0m7_CnkM6GY%2F-MRLXI_H7waLJVWyJMiL%2FV2%20-%20CreateIncidentInbound%201.png?alt=media\&token=7761aa75-027d-4c58-be74-6963e0a9979e)

5\) Click **Submit and view** to further configure the Message.

## Response Fields

Navigate to **Message > Response**.

The Response fields to be configured are as follows:

|  #  | Field         | Description                                                                                                                              | Value                                     |
| :-: | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
|  6  | Response      | The immediate synchronous response to this message.                                                                                      | \<lookup: 'Response'>                     |
|  \* | Async         | Turn this option on if you want inbound processing to occur asynchronously or this message is the first of an asynchronous message pair. | \<true>                                   |
|  7  | Async receipt | The asynchronous receipt to this message. Leaving this blank will cause the message to be processed async without sending a receipt.     | \<lookup: 'CreateIncidentInboundReceipt'> |

_\*This field is automatically defaulted to true._

_Your Response form should look like this:_

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLWta_N0m7_CnkM6GY%2F-MRLXX9pdCThyc18PV5y%2FV2%20-%20CreateIncidentInbound%202.png?alt=media\&token=a3186625-07e1-47a7-a986-c4c22d0bb674)

8\) Navigate to **Message > Bond**.

## Bond Fields

The Bond fields to be configured are as follows:

|  #  | Field               | Description                                                                                                                                                                                                 | Value    |
| :-: | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
|  \* | Bond ownership      | Determine if the sender should own the bond or not in order for this message to be processed? Use 'Ignore' to process regardless of the owner flag.  _(Choices: Ignore, Must own, Must not own.)_           | 'Ignore' |
|  \* | Bond condition type | The type of conditional check made on the bond. (_None:_ no checks are made. _State:_ checks against the state are made using the conditional checkboxes. _Scripted:_ the 'Bond condition' script is used.) | 'State'  |
|  9  | Bond new            | Process this message when a new bond is required.                                                                                                                                                           | \<true>  |

_\*These fields are automatically populated._

_Your Bond form should look like this:_

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLWta_N0m7_CnkM6GY%2F-MRLXgrWZGK7HgG-QHgy%2FV2%20-%20CreateIncidentInbound%203.png?alt=media\&token=15e08bd1-f680-4bdd-8933-f453d9b63de2)

10\) Navigate to **Inbound > Settings**.

## Inbound Settings Fields

The Inbound Settings fields to be configured are as follows:

|  #  | Field                   | Description                                                                                               | Value                                                                                     |
| :-: | ----------------------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|  \* | Bond reference method   | Method of searching for and validating an existing bond for incoming messages.                            | 'External'                                                                                |
|  11 | Reference lookup script | The script containing functions for extracting internal and external references from the request payload. | Update the code in the Reference lookup script field so that it looks like the code below |

{% hint style="info" %}
\*Bond reference method _(defaulted to 'External' & not editable for Create type Messages):_

_Internal -_ lookup using the internal reference only.

_External -_ lookup using the external reference only.

_Both -_ lookup using both the internal and external references.
{% endhint %}

{% hint style="success" %}
**Bond reference method:** The perspective of the available choices is in relation to the receiving instance i.e. Internal (internal reference) means the bonded ticket in our instance and External (external reference) means the bonded ticket in their instance. These settings define which values to lookup against to search for and validate whether or not a bond already exists.

In the case of a create type message (as per our requirement), it is defaulted to 'External' because there is not yet a bonded ticket in the receiving instance to reference _(if we were to receive a create type message which referenced a bond that already existed it would be rejected because we don't want to create another bond for a record we've already seen )_.
{% endhint %}

_The code in the 'Reference lookup script' field should look like this:_

```javascript
var answer = {};

answer.getExternalMessageID = function (payload, request) {
  return '' + (payload.message.source_id || '');
};

answer.getInternalMessageID = function (payload, request) {
  return '' + (payload.message.target_id || '');
};
```

{% hint style="info" %}
**Reference lookup script:** It’s important to identify which message an asynchronous receipt is replying to. This script extracts the transaction’s unique identifier.

In the case of an inbound create/update (as per our requirement) it would return their external message id (source id) to identify which transaction our asynchronous receipt belongs to. _(In the case of an inbound asynchronous receipt it would return our internal message id (target id) to identify which transaction their asynchronous receipt belongs to.)_
{% endhint %}

_Your Inbound Settings form should look like this:_

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLWta_N0m7_CnkM6GY%2F-MRLYbGEIit2Nj4PNiTP%2FV2%20-%20CreateIncidentInbound%204.png?alt=media\&token=49f5070d-491e-4c83-8763-6f4fb16fb8e8)

12\) Navigate to **Advanced > Script Editor**.

## Script Editor Fields

{% hint style="info" %}
As well as being the place where Bond state & ownership are set, the Scripts are where the request processing and data mapping occurs.
{% endhint %}

Click on **View > Inbound**.

The Script Editor fields to be configured are as follows:

|  #  | Field                     | Description        | Value                                                                               |
| :-: | ------------------------- | ------------------ | ----------------------------------------------------------------------------------- |
|  13 | Stage to Target (Inbound) | The script to run. | Replace the commented out instructions with the following code: **bond.setOpen();** |

## Scripts

{% hint style="info" %}
In the current release, there is no OOTB Field Map record with which we can set the state on the Bond. We shall, therefore, script that manually. For more information , see the \`[_Fields_](../../../configuration/fields)_\`_ & \`[_Field Maps_](../../../configuration/field-maps)_\`_ pages in our technical documentation.
{% endhint %}

_The code in the 'Stage to Target' script field should look like this:_

```javascript
bond.setOpen();
```

_Your Script Editor fields should look like this:_

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLWta_N0m7_CnkM6GY%2F-MRLZQvK21z283WimNqu%2FV2%20-%20CreateIncidentInbound%205.png?alt=media\&token=236609ac-d8b8-4640-8830-d96afc51e4af)

14\) Click **Save**.

15\) **Close** the Script Editor to navigate back to the Message.

We are now ready to configure the **Fields** for our **CreateIncidentInbound** Message.
