Toggle menu

Recording History

The startProcesssendMessage 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 historyRecording object with the following properties.

PropertyTypeDescription
labelsObjectThe 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 ${PROCESSNAME} and ${BUSINESSKEY}
subjectObjectThe history subject written when the workflow instance starts. processDefinitionId and processDefinitionKey are added automatically. Following convention you should supply a userId, proxyUserId and description. The description can be that set in the modeller using ${PROCESSDESCRIPTION}
eventObjectThe data you choose to store in an event is entirely arbitrary. We strongly advise following the History data conventions
storeFormDataBooleanIf true, "form data" will be stored in the event. See below for details
formNameStringIf storeFormData is true, this is the name of the form that will be used to display the data in products like Self Service
logSubmissionBooleanThis must be true for a history to be logged
logSummaryStringWhether 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 "_summaryForm" must be present, the value of which is the name of a published iCM form

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 startProcess, sendMessage and completeTask functions each include a "variables" property. If any of these variables have a name starting form_ they will be recorded in the formData event objects in exactly the same way as form submissions would store data.

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 historyRecording object with event and subject entries that match our standard conventions. History is being recorded when an End Point sends a message to a process instance.

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;
}

Last modified on August 01, 2023

Share this page

Facebook icon Twitter icon email icon

Print

print icon