Reset variable of Do While into Each Loop

Hello all,

I have Do While Activity counting day(xx)-> dayto (xx) into each loop department.
1 loop: day 20
but 2 loops: day 22

How can I reset day variable as begin (20). Day & Dayto can change, I set Int32

Thank all

Hi @anh.nguyen

Could you please elaborate your question then we will get better understanding to resolve the issue.

1 Like

Hi @anh.nguyen

While [condition]
Assign: day = 20 ’ Reset the day variable to its initial value before starting the loop

Do
    day = day + 1

Loop While [condition]

End While

Hope it helps!!

1 Like

Hi @anh.nguyen ,

We would need to look at the Do While loop workflow setup to properly provide the feedback.

But a Reset points out that there is a condition that needs to be checked and then the reset needs to happen.

1 Like

Hi @pravallikapaluri

day variable not fix, it can change when run

Hi, workflow and variable as the picture.

First each loop Phong (ACC) variable then While day variable (from day 20 - 21)
Second loop Phong (SHE) variable then While day variable (from day 20 - 21) but day variable is 22, it not correct, I want reset is 20


If you want to make the Day as 20 at the end of the loop take an If condition if DayToi >= 21 in then block Use the assign activity to change the value to 20.

Hope you understand!!

@anh.nguyen

After the while loop reinitialize your day variable to 20 again…just use an assign

cheers

1 Like

But day variable not fix is 20, it can change any number. How it know default first number (ex: 20)

@anh.nguyen

So you mean for each iteration of for loop would it start at 20 or any other number?

if any other number then is there some place it is saved what number it starts from

cheers

I mean when start , user will set the number of day variable, and it saved at here. and I want every loop will loop at begin day variable

Thank all
I think this is not best solution, temporary I add 1more Day1 and assign Day = Day1 after While
image
image

@anh.nguyen

got you…so the day value which you get in the default value should be preserved and used further everytime is it?

if so…before the for loop start assign the day variable to another variable say constantDay (use assign with constantday=day) and after the while loop use assign with day = constantday

cheers

1 Like

@anh.nguyen

Change the variable scope of Day from FLowChart to For Each

Regards

1 Like

@anh.nguyen

If you find the solution for your query please mark as solution to close the loop

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.