Using Scripts in an Operation Plan
You can implement complex execution logic involving multiple triggers using Java Script (JS) Scripts in Operation Plans. Scripts enable Operation Plans to conditionally execute actions.
JS Scripting
When the Event Trigger occurs, the JS script associated with a Counter is executed based on some conditions.
JS Scripting is made active on the Counter by switching on the
toggle in the tab of the Counter.![]() |
Measurement Point Triggers have a script associated with their Event Trigger Definition. If that script returns a boolean TRUE, the JS script associated with the Counter will be executed.
The Actions defined in the Counter are executed only if the JS Scripting is not active. The diagram below represents the way scripts are executed in Operation Plans.

In addition to the standard features of JS script, you can useFlkw:
functions to access the Operation Plan data for processing and decision-making. The script can execute the action(s) of the Counter based on the execution logic.
Consider a Counter with two Event Triggers and two Actions as shown below:


The JS script associated with the Counter performs some checks and executes the Action Create Tasks as seen below. Note that the script uses other Flkw:
functions to get data pertaining to the Counters and Operation Plan.

To add a JS script to a Counter:
Click the
toggle in the tab of the Counter. This makes JS Scripting active on this Counter.Add the JS script to be associated with the Counter.
You can use FieldLogs keywords(
Flkw:
functions) in your script, if required.
Business Requirement:
Quality Assurance in an organization that maintains the quality metrics of order fulfilment tasks performed by its workers. This is done by examining an order fulfilment task and evaluating the metrics based on the input entered by the worker.
The organization processes over 10,000 order fulfilment tasks everyday. The QA Department takes a random sample of 20% of the tasks to check if the tasks are completed to the required standard.

Solution:
20% sample = 1/5th of the tasks = One task for every five tasks completed.
To cover 20% of the tasks, one in every five tasks is considered by the system. When five tasks are completed, one of them is picked at random for the quality check.
This is repeated for every five tasks until all the tasks are completed by the system. The metrics are then generated.
Implementation using Scripts in Operation Plans:
The system records the Task ID of every task that is completed.
To cover 20% of tasks, one task for every five tasks is considered. When five tasks are completed, the system passes on the task IDs of all the five completed tasks to a QA check module. This module runs the quality check on a task selected at random from one of the five task IDs.
To support this solution, an Operation Plan is created. It has a Counter with two Triggers. One Trigger has a JS Script that saves the TaskID of every Task completed. The other has a JS Script that executes the Quality Check module to be run on one randomly chosen task of the five completed tasks (20% = 1/5). The structure of Operation Plan is given below.
![]() |
The scripts in the Operation Plan enable this execution logic as shown below.

The script ensures that the action of the Operation Plan is only executed if a condition is met.