# CreateIncidentInboundReceipt Fields

## Field: incident.number

{% hint style="info" %}
The ‘incident.number’ (Integration level) Field record should already be in place *(i.e. with Active set to false)*. *This was automatically created by Unifi when we first created the Message level record when completing the Incident Update Poller Guide*. We will now create its Message level counterpart.
{% endhint %}

From the **CreateIncidentInboundReceipt** Message, navigate to **Message > Fields**.

*Your CreateIncidentInboundReceipt Fields page should look like this:*

![](/files/hFCzss7he0F5h7c0BJWb)

Find the **incident.number** (Integration level) Field & set **Active** to **true**.

{% hint style="success" %}
The ‘Build Integration’ button becomes visible in the banner and the empty circle icon next to the Field name turns green & contains a green ‘check’ *(to indicate that Message level configuration exists for this Field)* when we set Active to true. *(Note: the empty 'circle icon' indicates that the Integration level Field is available to add to the Message.)*.
{% endhint %}

By setting the Active flag to true on the Integration level Field record listed on the Message, Unifi has automatically created the Message level counterpart.

## Build

We don't need to configure any more the Field records for the CreateIncidentInboundReceipt Message, so we are ready to build our message scripts.

![](/files/me1QxRTOjZhG6lUvf3PO)

Click on **Build Message**.

You will see the 'Message build successful' Info Message.

![](/files/64737HAFGTH1HPMqB2Xg)

Navigate to **Advanced > Script Editor > View > Outbound** to view the auto-generated code.

*Your Script Editor fields should look like this:*

![](/files/Z7utemsOGtOhwb6gOvXi)

## Message Scripts

We will look at the Message Scripts in turn.

***Source to Stage:***

*Your Source to Stage Message Script should look like this:*

```javascript
//===== [ws] Begin Unifi Auto Generated Code =====//

/*
 * This code (between the Begin and End comments) is generated from the
 * Field and Field mapping records which are configured as part of the integration.
 *
 * All code either above or below the comments will be automatically maintained
 * through the build cycle.
 *
 * WARNING: Do not edit the Begin or End comments.
 */

x_snd_eb.ws_console.checkpoint("MessageScript")

x_snd_eb.ws_console.execute("Mapping incident.number [x_snd_eb_field.do?sys_id=d4dba3aadb7dbc501831aab35b961994]", function () {
  log.debug("Field map: PI - String [x_snd_eb_field_map.do?sys_id=da997f7a1b51b81090dfdb9ebd4bcb5e]");
  
  var default_value = (function () {
    return '';
  })();
  
  // Determines whether this instance of the field map is for a mandatory field
  var is_mandatory = false;
  
  if (is_mandatory) {
    $stage.number = '' + (source.number || default_value);
  } else if (source.number != '') {
    $stage.number = '' + source.number;
  }

});

var error = x_snd_eb.ws_console.findCheckpointError("MessageScript");
if (error) throw error.message;

//===== [ws] End Unifi Auto Generated Code =====//
```

***Stage to Request:***

*Your Stage to Request Message Script should look like this:*

```javascript
//===== [ws] Begin Unifi Auto Generated Code =====//

/*
 * This code (between the Begin and End comments) is generated from the
 * Field and Field mapping records which are configured as part of the integration.
 *
 * All code either above or below the comments will be automatically maintained
 * through the build cycle.
 *
 * WARNING: Do not edit the Begin or End comments.
 */

x_snd_eb.ws_console.checkpoint("MessageScript")

x_snd_eb.ws_console.execute("Mapping incident.number [x_snd_eb_field.do?sys_id=d4dba3aadb7dbc501831aab35b961994]", function () {
  log.debug("Field map: PI - String [x_snd_eb_field_map.do?sys_id=da997f7a1b51b81090dfdb9ebd4bcb5e]");
  payload = payload || {};
  var $payload = payload;
  
  // Determines whether this instance of the field map is for a mandatory field
  var is_mandatory = false;
  
  if (is_mandatory) {
    $payload.correlation_id = '' + $stage.number;
  } else if ($stage.number) {
    $payload.correlation_id = '' + $stage.number;
  }

});

var error = x_snd_eb.ws_console.findCheckpointError("MessageScript");
if (error) throw error.message;

//===== [ws] End Unifi Auto Generated Code =====//
```

Next, we'll configure the **CreateIncidentInbound** 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.1/integration-guides/incident-create-poller-guide/messages/createincidentinboundreceipt-fields.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.
