Script

Type: script

This handler lets you run a script based on the items in a workflow.

The config for this handler is as follows:

{
    "script": "my script"
    "mimetype": "optional script mimetype (javascript by default)"
}

When writing your script, you will have access to variables containing document and workflow data:

  • workflow Current workflow
  • workflowTask - Current workflowTask
  • workflowData - Workflow metadata
  • documents - Array of documents being processed by the workflow

Example: Simple Publish

The following script is used as part of the Simple Publish workflow. It allows further scripts to know the most recent changesets associated with a workflow's documents, so that they can be reset to that version in the event the workflow is cancelled:

{
    "script": "workflowData.originalChangesetIds = {}; for (var i = 0; i < documents.length; i++) { workflowData.originalChangesetIds[documents[i].id] = documents[i].changesetId; }"
}