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.

Message Fields

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

Field Type Description
Number String The unique Message identifier.
Type Choice The primary purpose of the message.
Table Table name The table this message will be triggered from. This is typically the same as the target table defined on the process.
Application Reference The application containing this record.
Integration Reference The integration this record belongs to.
Active Boolean Set true to use this message for processing.
Description String The description for this message and the requirement it is meeting.
Message name String The message name that is unique for this integration.
XML Template String The template to be compiled when sending a message for an integration that is configured to use XML. Also handy for storing an example message which can be used as a reference on inbound messages.

Configuration Fields

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

Field Type Description
Direction* Choice The direction(s) this message is configured to support.
Response Reference The immediate synchronous response to this message.
Async Boolean Turn this option on if you want inbound processing to occur asynchronously or this message is the first of an asynchronous message pair (make sure to set a receipt message).
Async receipt Reference The asynchronous receipt to this message. Leaving this blank will cause the message to be processed asynchronously without sending a receipt.
Path URL A path to append to the URL defined in the connection. Specify a full URL to override the connection. Define inline scripts to reference Stage to Request script variables by wrapping code in braces {}, e.g. /{transaction.message_id}.
Action method String he 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.

*Direction choices: Inbound, outbound, or bidirectional.

Trigger Fields

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

Field Type Description
Send to self* Boolean Enable this option to allow this message to be sent even when the integration it belongs to has caused the update.
Attachment added Boolean Use this message to immediately send new attachments regardless of the trigger conditions.
Order Integer The order that outbound messages are processed in.
Outbound condition String The script that must be met for the message to be processed. Use current to get access to the triggering record.
Outbound condition Conditions The condition that the ServiceNow record must meet to trigger this message being processed.

*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.

Bond Fields

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

Field Type Description
Bond ownership* String 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.
Bond condition type String 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.
Bond reference method String 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.
Bond new Boolean Process this message when a new bond is required.
Bond pending Boolean Process this message when the bond state is Pending.
Bond open Boolean Process this message when the bond state is Open.
Bond suspended Boolean Process this message when the bond state is Suspended (internal suspend).
Bond vendor suspended Boolean Process this message when the bond state is Vendor suspended (external suspend).
Bond closed Boolean Process this message when the bond state is Closed.

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

Scripts Fields

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

Field Type Description
Reference lookup script Script plain The script containing functions for extracting internal and external references from the request payload.
Extract attachments Boolean Use the Extract attachments script to extract attachments from the inbound payload and prevent attachment data from being stored in the Request payload field.
Extract attachments script* Script plain The script used to extract attachment data from a request payload. Used to prevent writing attachment data to the request payload field (full payload can be attached using integration ‘Attach payloads’ option).

*Extract attachments script

This field is made visible when the Extract attachments box is checked.

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>