The startProcess, sendMessage and completeTask functions are able to log data to the platform's history service. This matches/supports the three form field types that carry out these same functions.
For more information about history, see the History Service documentation. For a more general introduction to how the workflow form fields and process activities record history data, see the Recording History During a Workflow Process knowledge base article.
historyRecording
Each of the three functions above has an optional
Property | Type | Description |
---|---|---|
labels | Object | The label a-e values for the history. By convention labela should be the process name and labelb the business key of the new instance. These can be accessed using the tokens |
subject | Object | The history subject written when the workflow instance starts. |
event | Object | The data you choose to store in an event is entirely arbitrary. We strongly advise following the History data conventions |
storeFormData | Boolean | If true, "form data" will be stored in the event. See below for details |
formName | String | If |
logSubmission | Boolean | This must be true for a history to be logged |
logSummary | String | Whether or not to generate a history summary event. The value will vary depending on the function being called. One of: "true": For start workflow, summaries are written when the process starts and ends For complete task and send message the summary event is logged "false": For start workflow, summaries won't be written when the process starts but will when it ends For complete task and send message the summary event is not logged "start": For start workflow, summaries are written when the process starts but not when it ends Not used on complete task or send message "never": For start workflow, summaries will not be written when the process starts or ends Not used on complete task or send message For summaries to be written a process variable named |
Tokens
A history is logged once an instance has started successfully or when a task has been completed. The workflow engine passes the following tokens back to the worker, allowing them to be logged in the history.
${PROCESSNAME} - the name of the process set in the modeller${PROCESSDESCRIPTION} - the description of the process et in the modeller${BUSINESSKEY} - the business key automatically generated by the workflow engine${TASKNAME} - the name of the user task that has just been completed${TASKDESCRIPTION} - the description of the user task that has just been completed
Form Data
The
For example, starting an instance with the following parameters:
{
"processDefinition": "chainedtasks",
"variables": {
"form_RADIOGROUP": "one",
"form_NAME": "Tim"
},
"formName": "STARTACHAIN",
"userName": "TIMG"
}
Results in an event which includes:
"formData": {
"data": {
"NAME": "Tim",
"RADIOGROUP": "one"
},
"formName": "STARTACHAIN",
"typeName": "FORM_STARTACHAIN",
"formDefinitionType": "FORMDEFINITIONEX"
}
Example
This snippet shows a complete
function(params, credentials) {
let message = this.callWorkerMethod("workflow", "sendMessage", {
"processInstanceBusinessKey": params.businessKey,
"messageName": "ReleaseTheHounds",
"variables": {
"newvariable": "A new value",
"anotherNewOne": "Another new value"
"form_NEWFIELD": "A third new value"
},
"userId": "TIMG",
"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": true,
"formName": "TIMSFORM",
"logSubmission": true,
"logSummary": "true"
}
});
return message;
}