SET Increment Counter in ServiceNow Flow

ServiceNow Flow Designer is a powerful platform that allows users to design, automate, and manage complex workflows without the need for extensive coding knowledge.

One of the key features of Flow Designer is the ability to use counter variables to keep track of iterations within a loop.

In this blog, we’ll discuss how to increment a counter variable in ServiceNow

Problem Statement:

  • We have a Do Until loop in Servicenow Flow designer and we want to end the loop when it reaches 745 iterations.


  • Implement the counter variable that does Counter = Counter + 1 on each iteration and then end the loop when it reaches 745.

Here are the actual steps that are required to be done in flow designer.

First click on 3 dots on the flow where you want to add variable

Now Name the variable and select Type, I named it as counter.

Now inside the flow before Do Until loop set the variable value of counter to zero.

Under Do Until Loop add the below script:

var data = fd_data.flow_var.counter + 1;

return data;

Now you can add the logic to end the flow based on iterations count.

If you are in the same situation and want to end the do until loop based on iterations count, you can utilize the above logic.



Thanks for reading …

Tech Wizard

PowerShell Fast Track



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s