Messages

A Message contains all the configuration required to send, receive, and process a request.

Messages are central to the functionality of Unifi. A Message brings together the disparate parts necessary for the configuration required in order to send, receive and process a request.

Automated Creation of Trigger Business Rule

Unifi will automatically create a Trigger (Business Rule) for the Process being integrated (if one doesn't already exist) when you run 'Build' either on the Integration or Message once your Create Message is configured.

For step-by-step instructions on how to configure Messages (and other Integration components) see the Integration Guides section of the documentation.

Message Fields

Details

The Details fields to be configured for the Message record are as follows:

*Direction choices: Inbound, Outbound, or Bidirectional.

The 'Disable' button will set the Active flag to 'false'.

Fields

From here you can configure the relevant Field records for the Message. A list of the available and active Fields is displayed*. For more information about Field records click here.

*The Fields displayed in this list are automatically filtered based on the table referenced on the Message (so you will only see relevant Fields).

Response

The Response fields to be configured for the Message record are as follows:

Bond

The Bond fields to be configured for the Message record are as follows:

*Bond ownership condition choices: Ignore, Must own, Must not own.

*Set bond owner choices: None, Internal, External.

'External' sets the bond.owner flag to true. 'Internal' sets it to false.

These settings will take precedence over any which are scripted in the Message Scripts.

*Set bo_nd state choices:_ None, Pending, Open Suspended, Vendor Suspended, Closed.

These settings will take precedence over any which are scripted in the Message Scripts.

Outbound Fields

Trigger

The Outbound Trigger fields to be configured for the Message record are as follows:

*Advanced condition:

This field is made visible when the 'Use advanced condition' field is set to true.

*Send to self:

By default, if an integration updates a target record it will not trigger messages to be sent back to itself, preventing feedback loops.

Template

The Template fields to be configured for the Message record are as follows:

CDATA

It is possible to use CDATA within an XML message, but because of the way ServiceNow handles XML it can be a little bit tricky. When ServiceNow see’s the CDATA tag, it actually processes it and the tag ends up being removed in the final. We need to use a little trick allow us to actually get the CDATA in the final result.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
  <g:evaluate jelly="true">
    var stage = jelly.jvar_stage, transaction = jelly.jvar_transaction;

    // initiate the attachment sender
    var sender = new x_snd_eb.AttachmentSender(
      jelly.jvar_transaction,
      jelly.jvar_bond
    );

    // we only handle one attachment - use in while loop if there are many
    sender.next();

    // we need CDATA to not be processed by XML
    // It's added in the XML below to wrap the embedded document
    var cdata = [
      '&lt;![' + 'CDATA[&lt;?xml version="1.0"?&gt;',
      ']]&gt;'
    ];
  </g:evaluate>
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.wsdl.com">
    <soapenv:Header/>
    <soapenv:Body>
      <wsdl:Request>
        <wsdl:RequestElement>
          <wsdl:server>dev.server.com</wsdl:server>
          <wsdl:formName>Attachment</wsdl:formName>
          <wsdl:id>ABC123</wsdl:id>
          <wsdl:xmlString>${cdata[0]}
            <Elements>
              <Element>
                <Name>Description</Name>
                <Value>Attachment Received from customer</Value>
              </Element>
              <Element>
                <Name>AttachmentName</Name>
                <Value>${HTML:sender.attachment_name}</Value>
              </Element>
              <Element>
                <Name>AttachmentData</Name>
                <Value><x-attachment-data sys_id="${sender.attachment_id}" /></Value>
              </Element>
            </Elements>${cdata[1]}</wsdl:xmlString>
          </wsdl:RequestElement>
        </wsdl:Request>
    </soapenv:Body>
  </soapenv:Envelope>
</j:jelly>

Attachments

The Outbound Attachments fields to be configured for the Message record are as follows:

*Attachment added:

This field is made visible when the 'Send attachments' field is set to true.

Settings

The Outbound Settings fields to be configured for the Message record are as follows:

Inbound Fields

Settings

The Inbound Settings fields to be configured for the Message record are as follows:

*Extract attachments script

This field is made visible when the Extract attachments box is checked. The script must always return a string and if an object is used it needs to be JSON encoded (i.e. JSON.stringify()). The following is an example:

payload = (function extractAttachments(payload, request) {
	
	// Convert from string to object
	var obj = JSON.parse(payload);
	
	// Extract the attachment here...
	
	// Update the payload
	payload = {
		attachment: ''
	};
	
	// Encode payload back to string
	return JSON.stringify(payload);
})(payload, request);

Advanced

Script Editor

From here you can view each of the Message Scripts for the Message (Source to Stage, Stage to Request, Payload to Stage, Stage to Target). The auto-generated code displayed is configured using Fields & Field Maps. For more information on Message Scripts click here.

You MUST NOT edit the code between the Begin & End Comments, or the comments themselves.

If you wish to manually script any code, that must be done outside of those comments.

Response Actions

From here you can view a list of the relevant Response Actions on the Integration. You can also configure a New Response Action from the list. For more information about Response Actions click here.

Event Actions

From here you can view a list of the relevant Event Actions on the Integration. You can also configure a New Event Action from the list. For more information about Event Actions click here.

The ServiceNow Administrator [admin] role is required to access Response/Event Actions.