Message Scripts

Message Scripts are where the request processing and data mapping occurs.

There are four different types of script which are used either before or after the Stage. Having these script types in relation to the Stage allows us to find any potential errors/discrepancies in data more easily.

  • Payload to Stage (Inbound)

    Data coming in is going to be translated (moved ‘as is’) from the Request to the Stage.

  • Source to Stage (Outbound)

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

    The following example extract from the Source to Stage Message Script shows location data being mapped:

if (!source.location.nil()) {
  stage.u_location_id =;
  stage.u_address = source.location.street;
  stage.u_town =;
  stage.u_county = source.state;
  stage.u_postcode =;
  stage.u_country =;
  stage.region = source.region;
  • Stage to Target (Inbound)

    Data coming in is going to be transformed (moved and changed) from the Stage to the target.

  • Stage to Request (Outbound)*

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

*The Stage to Request script is not always necessary as the translation can also occur in the XML Template.

For a list of the available variables for each of the four Message Scripts, click here.

In Unifi Integration Designer, you have visibility of your message scripts in the one pane; this makes scripting so much more efficient.

Although you are able to script directly in the Message Scripts, much of the scripting can now be done by configuring Fields & Field Maps (see below).

Bond State & Ownership

The Message Scripts can also be the place where Bond state & ownership are set manually (without using the control fields on Message).

The following Stage to Target Message Script from the AcknowledgeCreateIncident Message sets the Bond state to Open:

(function processStageToTarget(target, stage, transaction, bond, log) {

})(target, stage, transaction, bond, log);

The following extract from the Stage to Target Message Script for a CreateIncident Message shows the ownership of the Bond is with the internal system target.u_ebond_owner = true;; therefore, Bond ownership cannot be with the external system bond.setValue('owner', false);. It also shows the source of the Bond being identified as the unique Integration with the external system sending the Message target.u_ebond_source = transaction.integration; (which can be particularly useful with multi-vendor integrations).

// If this incident is being created in your instance then likely you are the owner
// Bond owner is set to false, as it is referring to the other system
bond.setValue('owner', false);

// We also update custom fields on the target record itself (i.e. Incident) so things like ACL rules can be used to restrict access to the Incident fields.
target.u_ebond_owner = true;
target.u_ebond_source = transaction.integration;

Bond state & ownership can now be configured without scripting by simply setting the values in the following fields:

  • Set bond owner inbound

  • Set bond state inbound

  • Set bond owner outbound

  • Set bond state outbound

For more details see the Message page.

Fields and Field Maps

Much of the scripting (including mapping of fields on the source/target record & other Transaction specific data e.g. Name, Time stamp, Source reference, Target reference) can now be done using Fields & Field Maps (see those pages for further details).

The configurations defined by Fields and Field Maps are compiled into executable code and stored in the Message Scripts (between demarkation comments). Existing Message Scripts simply have their code updated. Code outside of the demarkation comments in the Message Scripts is retained.