Skip to end of metadata
Go to start of metadata

Problem:

What is the JavaScript logic to capture the number of times a task got rejected? Ideally we are looking for a counter to capture the number of times a task got rejected.


Solution:

Create a variable e.g. times_rejected of type number. Reuse this variable in the JavaScript task.

if(timesRejected == null){
timesRejected = 1
} else {
timesRejected = timesRejected + 1
}

Adjust your workflow as shown: