Here we will deal with the configuration changes that need to be made to our CreateIncident Message to facilitate identifying and returning data from bonded records.
CreateIncident Message
Now that we've configured the remote system's Incident form to display our bonded ticket number as the correlation id, we need to update our CreateIncident Message to send it.
To ensure that our CreateIncident Message is sending the relevant data we need to configure a new Field record that will send the Incident number as the correlation id. We will make use of the previously copied String Field Map record.
Field: incident.number
In Unifi Integration Designer, from the CreateIncident Message, navigate to Message > Fields. Click New.
The fields to be configured for our incident.number New Field modal are as follows:
*These fields are automatically defaulted to true, or automatically populated.
**Field map: Value may vary. Choose the copy Field Map you created for your Integration.
Your 'incident.number' New Field modal should look like this:
6) Submit the record.
You will be redirected back to the Fields page of the CreateIncident Message.
Field: incident.description
It is not necessary to configure this Field record to facilitate identifying and returning data from bonded records. It is only included here to facilitate the sending of data in the Description field of the Incident when testing our Integration. You may choose to ignore this if you wish. Similarly, if you had already configured the incident.description Field record for the CreateIncident Message (when completing the 'Outbound incident' Guide), you can ignore this.
The ‘incident.description’ (Integration level) Field record should already be in place (i.e. with Active set to false). This was automatically created by Unifi when we created the Message level record when configuring the Fields for the UpdateIncidentInbound Message. We will now create its Message level counterpart for the CreateIncident Message.
From the CreateIncident Message, navigate to Message > Fields.
Your CreateIncident Fields page should look like this:
7) Find the incident.description (Integration level) Field & set Active to true.
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. (The ‘Build Integration’ button became visible in the banner when we created the 'incident.number' Field record.)
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.
8) Click to open the incident.description (Message level) Field to make a few minor changes.
The incident.description Field record opens to the Details page.
9) Navigate to Field > Settings.
Edit the incident.description Field record as follows:
Your 'incident.description' Field record should look like this:
13) Save the record.
Build
Now that we’ve configured the Field records for the CreateIncident message, we are ready to build our message scripts.
To quickly navigate to the CreateIncident Message from the Details page of the newly created incident.description Field record...
...click the 'Preview' icon to the left of the Message field.
The following Field records should now be in place for your CreateIncident Message:
14) Click on Build Message.
You will see the 'Message build successful' Info Message.
15) Navigate to Advanced > Script Editor > View > Outbound to view the auto-generated code.
Your Script Editor fields should look like this:
Message Scripts
The new auto-generated code (mapping the incident number to the correlation id & mapping the Incident description) will appear between the Begin & End Comment along with the code that was already there (which we had previously created using the Outbound Incident Guide). Your code may differ, depending on which Field records you created to satisfy your mapping requirements.
Source to Stage:
//===== [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.caller_id [x_snd_eb_field.do?sys_id=f23b349edb359010853c561bdc961989]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$stage.caller_id =''+ (source.caller_id || default_value); } elseif (source.caller_id !='') {$stage.caller_id =''+source.caller_id; }});x_snd_eb.ws_console.execute("Mapping incident.description [x_snd_eb_field.do?sys_id=009447071b0214105830db9ebd4bcb22]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$stage.description =''+ (source.description || default_value); } elseif (source.description !='') {$stage.description =''+source.description; }});x_snd_eb.ws_console.execute("Mapping incident.number [x_snd_eb_field.do?sys_id=e75407071b0214105830db9ebd4bcbf7]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$stage.number =''+ (source.number || default_value); } elseif (source.number !='') {$stage.number =''+source.number; }});x_snd_eb.ws_console.execute("Mapping incident.short_description [x_snd_eb_field.do?sys_id=548efc12db759010853c561bdc961918]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$stage.short_description =''+ (source.short_description || default_value); } elseif (source.short_description !='') {$stage.short_description =''+source.short_description; }});x_snd_eb.ws_console.execute("Mapping incident.state [x_snd_eb_field.do?sys_id=b5e1c9d2db759010853c561bdc961929]", function () {
log.debug("Field map: IS - Choice [x_snd_eb_field_map.do?sys_id=a58d2401db39985094dbd7795e9619fd]");var default_value = (function () {return''; })();var field_choice;var is_mandatory =false; if (!source.state.nil()) { field_choice =newGlideRecord('x_snd_eb_field_choice');field_choice.addQuery('table','=','incident');field_choice.addQuery('element','=','state');field_choice.addQuery('integration','=','642bd074dbb9585094dbd7795e9619a7');field_choice.addQuery('field.message','=','');field_choice.addQuery('direction','=','Outbound');field_choice.addQuery('value','=',source.state);field_choice.addQuery('active','=','true');field_choice.query();if (field_choice.next()) {$stage.state =''+field_choice.external_value; } } if (!$stage.state) {$stage.state =''+ (source.state ||''); }if (is_mandatory) {$stage.state =''+ (source.state ||''); }});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:
//===== [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.caller_id [x_snd_eb_field.do?sys_id=f23b349edb359010853c561bdc961989]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$payload.caller_id =''+$stage.caller_id; } elseif ($stage.caller_id) {$payload.caller_id =''+$stage.caller_id; }});x_snd_eb.ws_console.execute("Mapping incident.description [x_snd_eb_field.do?sys_id=009447071b0214105830db9ebd4bcb22]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$payload.description =''+$stage.description; } elseif ($stage.description) {$payload.description =''+$stage.description; }});x_snd_eb.ws_console.execute("Mapping incident.number [x_snd_eb_field.do?sys_id=e75407071b0214105830db9ebd4bcbf7]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$payload.correlation_id =''+$stage.number; } elseif ($stage.number) {$payload.correlation_id =''+$stage.number; }});x_snd_eb.ws_console.execute("Mapping incident.short_description [x_snd_eb_field.do?sys_id=548efc12db759010853c561bdc961918]", 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 fieldvar is_mandatory =false;if (is_mandatory) {$payload.short_description =''+$stage.short_description; } elseif ($stage.short_description) {$payload.short_description =''+$stage.short_description; }});x_snd_eb.ws_console.execute("Mapping incident.state [x_snd_eb_field.do?sys_id=b5e1c9d2db759010853c561bdc961929]", function () {
log.debug("Field map: IS - Choice [x_snd_eb_field_map.do?sys_id=a58d2401db39985094dbd7795e9619fd]"); payload = payload || {};var $payload = payload;var is_mandatory =false; if (is_mandatory) {$payload.state =$stage.state; } elseif ($stage.state) {$payload.state =$stage.state; }});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 =====//
We have now completed the configuration and are ready to move on to Test our Update Scenario.
#
Field
Description
Value
*
Message
The Message this Field record is linked with.
'CreateIncident'
1
Description
The description of this Field record.
'The incident number sent as the correlation id'
*
Active
Set to true to use this Field record for processing.
<true>
2
Field map
The Field Map this Field record is linked with.
'IS - String'**
*
Map to field
Use this Field record to represent a field on a source/target table.
<true>
*
Table
The primary source/target table that this Field record is mapped to.
'Incident' [incident]
3
Element
The field on the source/target table this Field record is mapped to.
'Number'
4*
Property
The property in the payload the data will be written to.