do while loop is not working in flow designe

jay97
Tera Contributor

Hello Guys,

 

I have used the below code in the flow designer for the print logs. but it is running only for the one times in flow designer. 

 

var loop count=0;
var i= 0;
do {
loop_count=loop_count+1;
console.log(num);
i++;
}
while (i < 5);

 

output: 1,2,3,4,5

 

here loop count is integer .it is running only one time only.

 

i have added add operation over here one loop_count  but not getting output 1,2,3,4,5 system log. please help

jay97_1-1669342656834.png

jay97_2-1669342721855.png

 

 

 

 

2 ACCEPTED SOLUTIONS

newhand
Mega Sage

@jay97 

 

>>it is running only one time only.

YES,because you writed [less than 5] at the [until] part ....

The first time you run the loop...the  [loop_count] becomes 1  ,and it  is  [less than 5]  ,so the loop is ended.

 

you need to change [less than 5] to [more than 5]...

 

 

Please mark my answer as correct and helpful based on Impact.

View solution in original post

As per the image you provided earlier, your flow variable's backend name is not loop_count. See the below image which you provided.

MuhammadKhan_0-1669356657489.png

 

So, in your script, use the proper backend name of your flow variable. In my case it was loop_count.

MuhammadKhan_1-1669356738321.png

 

return fd_data.flow_var.<backend_name_of_your_flow_variable> + 1;

 

 

View solution in original post

10 REPLIES 10

Muhammad Khan
Mega Sage
Mega Sage

It would be something like below.

MuhammadKhan_3-1669346069613.png

 

Output

MuhammadKhan_4-1669346231250.png

 

 

Set Flow Variables

MuhammadKhan_0-1669345950078.png

Log

MuhammadKhan_1-1669346019013.png

Until

MuhammadKhan_2-1669346045718.png

 

jay97
Tera Contributor

thank you for your inputs . Could you please tell what you have set type of variable in the flow designer ?

newhand
Mega Sage

@jay97 

 

>>it is running only one time only.

YES,because you writed [less than 5] at the [until] part ....

The first time you run the loop...the  [loop_count] becomes 1  ,and it  is  [less than 5]  ,so the loop is ended.

 

you need to change [less than 5] to [more than 5]...

 

 

Please mark my answer as correct and helpful based on Impact.