Trigger custom scripts on workflow states

As a library administrator, you can configure custom actions to trigger a specific custom script when a document enters or leaves a workflows state.

1. Access the library administration and select Workflows.

2. Click a workflow name to open the workflow configuration.

3. Select a workflow state and click Customize to configure a new custom action.

4. Click Add new action

Note: You can configure multiple custom actions in one workflow state.

5. Fill in the settings of the newly created custom action:

  • Action name: This value can be retrieved in your custom script by calling the method _getDisplayName
  • Event:
    • run when document enters this state before inbound transition is completed
    • run when document enters this state after inbound transition is completed
    • run when document leaves this state before outbound transition is completed
    • run when document leaves this state after outbound transition is completed

These options let you choose exactly when to run the custom script. 

Note: If you select either of the options where the custom script runs before the transition is completed, the document is already locked when the custom script runs because the workflow transition is in progress (red dotted lines in the examples below). This means the custom script can't update the document. These options are used to check information in the document, such as whether a given property has a given value or whether the document has a given attachment.

Usually you want the custom script to update the document, so you need to run it after either the inbound or outbound transition is completed. 

If you have one state that transitions to several possible states, select run when document leaves this state after outbound transition is completed

In the example workflow below, the workflow sends bills for validation to different people. When the workflow transition is triggered, the custom script updates a property indicating who sent the bill for validation and the bill is sent to the approver they choose. Here, the custom script runs when the document leaves the "Send bill for validation" state, after the outbound transition is completed (black dotted line).

This means you only have to configure one state: "Send bill for validation".

run custom scripts1.png

If you have several possible states that transition to one state, select run when document enters this state after inbound transition is completed.

In the example workflow below, contracts can be approved by different people. Here, the custom script runs updates a property indicating the date the contract was approved. It runs when the document enters the "Contract approved" state, after the inbound transition is completed (black dotted line).

This means you only have to configure one state: "Contract approval".

run custom scripts2.png 

  • Script name: Select the custom script you want to trigger from the drop-down list. 

Note: You can only select Workflow Transition Action custom scripts. Learn more: Create custom scripts.

6. Check the Parameters table.

Tip: As a custom script can be triggered on several workflow states, the custom script code can call specific parameters from the Parameters table. When configuring a custom script action, you can modify the second column Values of the Parameters table to adapt the custom script for the action you are configuring. 

image 01.png

Was this article helpful? 3 out of 6 found this helpful
If you didn’t find what you were looking for, don’t hesitate to leave a comment!
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.