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
Name | Type | Description |
---|---|---|
fileReferences | Object | Map 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 |
historyRecording | Object | See Recording History |
replaceExistingFiles | boolean | True 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 |
messageName | String | The name of the message event (the message reference set in an event in the workflow modeller) |
processInstanceBusinessKey | String | The business key of the process instance to send the message to |
processInstanceId | String | The ID of the process instance to send the message to |
proxyUserId | String | Can be used instead of |
startUserId | String | A 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 |
userId | String | This value will be logged in the |
variables | Object | Map 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;
}