Message Fields

  • Navigate to [ws] Unifi > Configuration > Messages > New.*

    *Alternatively (from the previously created Message record), update the field values as per the table below, then right-click the header & ‘Insert and Stay’.

  • The Message fields to be configured for the CreateIncident Message are as follows:

# Field Description Value
1 Type The primary purpose of the message. ‘Create’
2 Table The table this message will be triggered from. This is typically the same as the target table defined on the process. ‘Incident’ [incident]
3 Integration The integration the record belongs to. < lookup: Integration ‘Name’ >
4 Active Set true to use this message for processing. < checked >
5 Message name The message name that is unique for this integration. ‘CreateIncident’

The top section of your CreateIncident Message record should look like this:

CreateIncident Fields

‘Configuration’ Tab Fields

  • Click on the ‘Configuration’ tab and configure the fields as follows:
# Field Description Value
1 Direction The direction(s) this message is configured to support. ‘Outbound’
2 Response Use the Extract attachments script to extract attachments from the inbound payload and prevent attachment data from being stored in the Request payload field. < lookup: ‘CreateIncidentResponse’ >
3 Action method The SOAP Action or the REST Method to use for this message. If this field is empty the SOAP Action will default to the message name and the REST Method will default to GET. ‘POST’

Your ‘Configuration’ tab should look like this:

CreateIncident Configuration

‘Trigger’ Tab Fields

  • Click on the ‘Trigger’ tab and configure the fields (as required)* as follows:
# Field Description Value
1 Outbound condition* The condition that the ServiceNow record must meet to trigger this message being processed. < Your condition > e.g. ‘Short description contains starter’

*Outbound condition (as required):

It is not necessary for you to enter a condition. The value given is an example. You may create any condition (or not) to align with your business process requirements.

Your ‘Trigger’ tab should look like this:

CreateIncident Trigger

‘Bond’ Tab Fields

  • Click on the ‘Bond’ tab and configure the fields as follows:
# Field Description Value
1 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’
2 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’
3 Bond reference method Method of searching for and validating an existing bond for incoming messages. (Internal: lookup using the internal reference only. External: lookup using the external reference only. Both: lookup using both the internal and external references.) ‘Internal’
4 Bond new Process this message when a new bond is required. < checked >

Your ‘Bond’ tab should look like this:

CreateIncident Bond

‘Scripts’ Tab Fields

  • All of the values in the ‘Scripts’ tab fields are to be left as-is.
  • ‘Save’ the record.
  • Configure the following Message Scripts by clicking on ‘New’ in the related list:

Message Scripts

Message Scripts

As previously stated, Message Scripts are where the request processing and data mapping occurs. They are also the place where Bond state & ownership are set.

_Source to Stage (Outbound)_

Data going out is going to be transformed (moved and changed) from the source to the Stage.

  • The Message Script fields to be configured are as follows:
# Field Description Value
1 Type The type of message script. ‘Source to Stage (Outbound)’
2 Script* The script to run. Replace the ’// Add your code here’ with your field mapping code (see below):

*Script:

The code in the script field should look like this (the mappings below match the requirements of this guide - they may differ according to the requirements of your integration):

(function processSourceToStage(source, stage, transaction, message, bond) {

	stage.u_caller_id = source.caller_id.user_name + '';
	stage.u_short_description = source.short_description + '';
	stage.u_description = source.description + '';
	stage.u_category = source.category + '';
	stage.u_impact = source.impact + '';
    stage.u_urgency = source.urgency + '';
    stage.u_priority = source.priority + '';
	stage.u_state = source.state + '';
	stage.u_comments = source.comments + '';
	stage.u_worknotes = source.work_notes + '';

})(source, stage, transaction, message, bond);

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

CreateIncident Source to Stage

  • ‘Submit’ the record.

  • Configure the second Message Script by again clicking on ‘New’ in the related list:

_Stage to Request (Outbound)_

Data going out is going to be translated (moved as-is) from the Stage to the Request.

  • The Message Script fields to be configured are as follows:
# Field Description Value
1 Type The type of message script. ‘Stage to Request (Outbound)’
2 Script* The script to run. Replace the ’// Add your code here’ with the code shown so that it looks like the code below:

*Script:

The code in the script field should look like this (as previous, the mappings below match the requirements of this guide - they may differ according to the requirements of your integration):

(function processStageToRequest(request, stage, transaction, message, bond, scratchpad) {

	headers['Content-type'] = 'application/json';

	payload = {
		caller_id: stage.getValue('u_caller_id'),
		short_description: stage.getValue('u_short_description'),
		description: stage.getValue('u_description'),
		category: stage.getValue('u_category'),
		impact: stage.getValue('u_impact'),
		urgency: stage.getValue('u_urgency'),
		priority: stage.getValue('u_priority'),
		state: stage.getValue('u_state')
	};

	if (!stage.u_comments.nil()) payload.comments = stage.getValue('u_comments');
	if (!stage.u_worknotes.nil()) payload.work_notes = stage.getValue('u_worknotes');

	payload = JSON.stringify(payload);

})(request, stage, transaction, message, bond, scratchpad);

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

CreateIncident Stage to Request

  • ‘Submit’ the Message Script.

  • ‘Update’ the CreateIncident Message record.

We are now ready to configure our UpdateIncidentResponse Message.