User Tools

Site Tools




The PerspectiumMessage object provides a way to create PSP messages in script that can placed into the Outbound Messages queue for sending out. These messages generally contain topic, type, key, name and value fields with extra and attributes being additional optional fields:
Note any other fields you see in the above screenshot are for ServiceNow only (such as the Created and State fields) and will not appear in messages as sent to MBS.

PerspectiumMessage can be used anywhere server side javascript is supported such as in a bulk share's Before/After Bulk Share Script.

To use this object, you first need to initialize it:

Initialize Description
PerspectiumMessage(topic, type, key, name, value, target_queue, extra, attributes, shareGR, set_id) initializes PerspectiumMessage with the following arguments:
topic (required)a value for the topic field of the message such as “replicator”
type (required)a value for the type field of the message such as “servicenow”
key (required)a value for the key field of the message, generally the instance name
name (required)a value for the name field of the message such as “incident.bulk”
value (required)a value for the value field of the message
target_queue (optional)The target queue (u_psp_queue) sys id where the message should be sent to
extra (optional)a value for the extra field of the message
attributes (optional)a value for the attributes field of the message
shareGR (optional)a share configuration to associate with this message. This is useful if you want this message to show up in a dynamic or bulk share's related list of logs
set_id (optional)a Message Set Activity set_id to send with this message in the attributes field
state (optional)a value for the state field of the message. If no value is passed, message will be created with a state of “Ready” so it can be processed and sent to the Perspectium MBS server

Once initialized, you can reference the PerspectiumMessage functions (unless specified, functions are available in v3.6.0+):

Methods Description Version
enqueue() queues the message into the Outbound Messages queue in the “ready” state so it can be sent
encodeMessageJSON() returns string - the message as a JSON string 3.7.0+
setTopic(topic)sets the value of the message's topic field with the topic argument
setType(type)sets the value of the message's type field with the type argument
setKey(key)sets the value of the message's key field with the key argument
setName(name)sets the value of the message's name field with the name argument
setValue(value)sets the value of the message's value field with the value argument
setTargetQueue(target_queue)sets the message's target_queue with the target_queue argument
setExtra(extra)sets the value of the message's extra field with the extra argument
setAttributes(attributes)sets the value of the message's attributes field with the attributes argument
setSetId(set_id)sets the value of the message's set_id field with the set_id argument
setShareGr(shareGR)sets the message's share configuration with the share configuration GlideRecord argument
setState(state)sets the value of the message's state field with the state argument
appendAttribute(attrKey, attrVal)appends an attribute to the message's attributes field in the format of attrKey=attrVal. For example, appendAttribute(“action”, “pause”) will append “action=pause” to the message's attributes

For example, the following script shows a message created with a topic of “monitor”, type of “label”, key of “dev_instance”, name of “bulk share completed” and a value of “2016-01-01 00:00:00” and then queued to be sent out:

var pm = new PerspectiumMessage("monitor", "label", "dev_instance", "bulk share completed", "2016-01-01 00:00:00", bulkshare_gr.u_target_queue, "", "", bulkshare_gr, "");

This script was ran in a bulk share's Before Bulk Share Script so it was utilizing the “bulkshare_gr” GlideRecord object available in Before Bulk Share Script in order to send out the message to the bulk share's target queue. The above example only shows how to create and queue up a message for sending. Please contact support for more information on how to use this functionality and the type of messages that can be sent.

updateset_perspectium_api_message.txt · Last modified: 2016/10/31 21:11 by paul