# 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:*

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLV3CNPFDXfmnZ25YZ%2F-MRLVgIH_siqHyv_7-1C%2FV2%20-%20Fields%20CreateIncidentInboundReceipt%201.png?alt=media\&token=ee43b4cb-d542-497d-a132-3788b245cae4)

1\) 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.

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLV3CNPFDXfmnZ25YZ%2F-MRLW2dBvyKP1y0c0aOn%2FV2%20-%20Fields%20CreateIncidentInboundReceipt%202.png?alt=media\&token=914242ea-91b4-413b-bef6-70106c5c40d0)

2\) Click on **Build Message**.

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

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLV3CNPFDXfmnZ25YZ%2F-MRLWYQOttIohQo4x0Vg%2FV2%20-%20Fields%20CreateIncidentInboundReceipt%203.png?alt=media\&token=7fbc00b5-d471-4837-b9cb-b045ea34de05)

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

*Your Script Editor fields should look like this:*

![](https://796541950-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBk35gIi557UHt7QlJ%2F-MRLV3CNPFDXfmnZ25YZ%2F-MRLWcfJcn7J5F7xt6cY%2FV2%20-%20Fields%20CreateIncidentInboundReceipt%204.png?alt=media\&token=4ed24203-bbc6-48ad-a983-b0c8c12e985f)

## 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.execute("Mapping incident.number [x_snd_eb_field.do?sys_id=c7a87254dbaa141041f945e81396195e]", function () {
  log.debug("Field map: IS - String [x_snd_eb_field_map.do?sys_id=006de8cddbf5985094dbd7795e96191e]");

  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;
  }

});

if (x_snd_eb.ws_console.has_error) {
  var errors = x_snd_eb.ws_console.get({type: 'error'});
  if (errors.length) {
    throw errors[0];
  }
}

//===== [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.execute("Mapping incident.number [x_snd_eb_field.do?sys_id=c7a87254dbaa141041f945e81396195e]", function () {
  log.debug("Field map: IS - String [x_snd_eb_field_map.do?sys_id=006de8cddbf5985094dbd7795e96191e]");
  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;
  }

});

if (x_snd_eb.ws_console.has_error) {
  var errors = x_snd_eb.ws_console.get({type: 'error'});
  if (errors.length) {
    throw errors[0];
  }
}

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

Next, we'll configure the **CreateIncidentInbound** Message.
