Toggle menu

sendMessage

Sends a message to a process instance.

Before sending a message you must know the business key or ID of the instance you'd like to send a message to. Your message reference must match a message event in the workflow model.

If your workflow model has multiple events with the same message reference then all of them will be triggered (assuming the execution has arrived at them).

Note that sendMessage behaves synchronously. In the process you are messaging, we recommend setting the first activity after the one that receives your message as asynchronous.

Parameters

NameTypeDescription
fileReferencesObjectMap of field names to file reference objects. The supplied files will be referenced by the workflow and remain available until it completes. For an example see the startProcess function
historyRecordingObjectSee Recording History
replaceExistingFilesbooleanTrue by default. If this property is true, files named in the "fileReferences" parameter replace any existing files provided under that name which will no longer be referenced by the workflow. Otherwise the new file and and any previous files referenced under that name will be kept
messageNameStringThe name of the message event (the message reference set in an event in the workflow modeller)
processInstanceBusinessKeyStringThe business key of the process instance to send the message to
processInstanceIdStringThe ID of the process instance to send the message to
proxyUserIdStringCan be used instead of userId
startUserIdStringA username. If supplied, the worker will verify that this matches the start user of the process before sending the message, providing a way to add an extra level of security
userIdStringThis value will be logged in the signalName_received process variable. It needn't be the name of an actual user in iCM. See the Process Variables articles for more information
variablesObjectMap of process variables to update or create, where the keys are process variable names and the values are the values of those variables
messageName and either processInstanceBusinessKey or processInstanceId are required

Example Request

This example sends a message, adds new process variables to the instance, and records a history event in the main history generated when the process instance started.

function(params, credentials) {
    let message = this.callWorkerMethod("workflow", "sendMessage", {
        "processInstanceBusinessKey": params.businessKey,
        "messageName": "ReleaseTheHounds",
        "variables": {
            "newvariable": "newValue",
            "anotherNewOne": "another new value"
        },
        "userId": "TIMG",
        "startUserId": "ANONYMOUS",
        "historyRecording": {
            "labels": {
                "labela": "${PROCESSNAME}",
                "labelb": "${BUSINESSKEY}"
            },
            "subject": {
                "description": "${PROCESSDESCRIPTION}",
                "userId": "TIM",
                "proxyUserId": null
            },
            "event": {
                "event": "MESSAGE",
                "description": "Message Sent",
                "userRole": "user",
                "userId": "TIM",
                "proxyUserId": null,
                "private": false
            },
            "storeFormData": false,
            "formName": "TIMSFORM",
            "logSubmission": true,
            "logSummary": false
        }
    });
    return message;
}

Last modified on March 27, 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon