Search…
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:
1
if (!source.location.nil()) {
2
stage.u_location_id = source.location.name;
3
stage.u_address = source.location.street;
4
stage.u_town = source.location.city;
5
stage.u_county = source.state;
6
stage.u_postcode = source.zip;
7
stage.u_country = source.country;
8
stage.region = source.region;
9
}
Copied!
    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.
The following Stage to Target Message Script from the AcknowledgeCreateIncident Message sets the Bond state to Open:
1
(function processStageToTarget(target, stage, transaction, bond, log) {
2
3
bond.setOpen();
4
5
})(target, stage, transaction, bond, log);
Copied!
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).
1
// If this incident is being created in your instance then likely you are the owner
2
// Bond owner is set to false, as it is referring to the other system
3
bond.setValue('owner', false);
4
5
// 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.
6
target.u_ebond_owner = true;
7
target.u_ebond_source = transaction.integration;
Copied!
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.
Last modified 3mo ago
Export as PDF
Copy link