Adding a Script
Using Scripts, you can modify Template behavior when the Task is being run. A Script can be added to any Step in a Template.
Important
Only users with the
privilege can add or edit Scripts.To add a Script to a Step, the following need to be set:
Script Triggers : The event on the Step which will trigger the Script.
Script Instructions: The instructions that comprise the Script. The Script is executed when the Script Trigger event occurs.
Any one of the following four events can trigger a Script associated with a Step.
In FieldLogs, Validation of a Step refers to the event of saving the Step value to the Task.
Event Trigger | Description |
---|---|
AfterValidate | Triggers the Script when the Step is validated by the user, after the value is saved in the Task. |
BeforeValidate | Triggers the Script when the Step is validated by the user, before the value is saved in the Task. |
OnLoad | Triggers the Script when the Task execution starts or restarts (after the application stops, for example) or when the Task is continued. |
AfterAnyValidation | Triggers the Script each time any Step of the Task is validated by the user, after the value is saved in the Task. |
A Script can be broken down into several simple Instructions. A Script Instruction performs a single action.
A Script Instruction can be of the following categories:
Category | Description |
Basic | Basic operations like evaluation of expressions. |
Step value | Reading and Setting the values and properties of Steps. |
Global Value | Reading and Setting Global values and Template Variable values. |
External call | Making external function calls. |
Table | Manipulating values in a Table Step. |
Identity | Accessing and evaluating Identity and Role related conditions |
Logic | Conditional Execution of statements. |
JS Execute | Enables Enhanced Scripting. |
To create a Script:
Open the Template to which the Script needs to be associated.
Select the Step whose event needs to trigger the Script. Navigate to the
as shown below.The
opens.The
button acts as a toggle button between the Step numbers and Step IDs.This button is accessible at every stage of the Template Lifecycle. It is also visible on Published Templates as shown below.
Click
.Enter the name of the Script. Choose the appropriate trigger for the Script.
Click the
to add a new Script instruction. Based on the type of Instruction selected, further options appear.
Add as many Instructions as required by clicking the
button. Delete any Instruction by clicking the
button.
For more details, see Script Instructions.
Save the Template.
The Script is now associated with the Template.
Note
You can associate multiple Scripts to the same Step.
In the below example, all the Scripts are associated with the same Step. Note that in some cases the same event on the same Step can trigger multiple Scripts.
![]() |
Tip
You can use the Execution Preview to preview the Script execution.
![]() |