Skip to content

Working with workflows

Content Script Workflow Steps

The Content Script Extension for Workflows is automatically available upon installation of the Content Script module. The extension enables a new workflow package in Workflow maps (Content Script package) and custom type of workflow step (Content Script step).

Content Script Package

The Content Script package must be enabled in order to use Content Script steps within a workflow map.

Once enabled, it will be possible to define the set of Content Script objects that will be available for inclusion in the current workflow map.

Content Script Workflow Step

Content Scripts enabled in the workflow package can be used in the workflow map as Content Script steps.

Here below is an example of a Content Script step performing some basic operations on the current workflow task.

// Fetch the menu in its original format
def workflowStatus  = workflow.getWorkflowStatus(workID, subWorkID)
def workflowTask  = workflow.getWorkFlowTask(workID, subWorkID, taskID)
def allTasks   = workflowStatus.tasks 

// Edit Workflow Attribute values
def workflowAttributes = workflowStatus.getAttributes()
workflowAttributes.setAttributeValues("Customer", "ACME inc.")
workflowAttributes.setAttributeValues("Country", "Switzerland")
workflow.updateWorkflowData(workID,  subWorkID, [workflowAttributes]) //Updates attributes

// Edit  Workflow Attribute values - different flavour

    def atts =workflowStatus.getAttributes()

    // This API is not just for reading values...  
    // Set the value = "ACME inc." = "Switzerland"

    workflowStatus.updateData() // COMMIT CHANGES

    log.error("Unable to access workflow's attributes ",e)

// Access a workflow form
def form = forms.getWorkFlowForm(workflowTask, "Form")  
form.myattribute.value = "A new value"
forms.updateWorkFlowForm(workflowTask, "Form", form, false)

// Update Task's title
                          "Title with form field: ${form.myattribute.value}"

// Access a workflow form and workflow attributes - different flavour
node = asCSNode(path:"Some Path:On Content Server:Node")

workflowStatus.attributes."Account Folder" = node.ID"Lead Owner" = node.Account."Account Manager""Company" = node.Account."Company name""First Name" = node.Account."Contacts"."First Name""Last Name" = node.Account."Contacts"."Last Name""Email" = node.Account."Contacts"."Email""Addresses"."Street" = node.Account."Addresses"."Street""Addresses"."City" = node.Account."Addresses"."City""Addresses"."Zip Code" = node.Account."Addresses"."ZipCode""Addresses"."Country" = node.Account."Addresses"."Country"
workflowStatus.updateData()   // COMMIT CHANGES

// Updating Workflow title
                              "Company: ${"Company" as String}"

// Add documents to the attachments folder (an empty spreadsheet in this case)
def workflowAttachments = workflowStatus.getAttachmentsFolder()
workflowAttachments.createDocument("Spreadsheet", xlsx.createSpreadsheet().save()) 

In the above example, the script is:

  • fetching information related to the current workflows status and tasks

  • performing changes on some workflow attributes

  • fetching and updating a workflow form

  • adding attachments to the workflow attachments folder

Note that the above script makes use of some context variable available in the execution context that are peculiar only to workflow steps. The variables are:

Expression type Type Description
workID Integer The workflow ID
subWorkID Integer The subworkflow ID
taskID Integer The current task ID

The above variables can be used in combination with the workflow service API to access all the information related to the current workflow. See the complete API documentation for a complete list of operations available on workflow instances.

Workflow routing

Content Script execution outcome, which MUST always be a String, can be interpreted in different ways, and used to route the next steps of the workflow.

The following routing expression types are currently supported:

Expression type Values Description
Content Script Outcome Success or Error Error in case the script returns an exception
Content Script Outcome (Integer) Any Integer value Supports evaluation based on numeric comparison
Content Script Outcome (String) Any String value Evaluation based on string comparison