Variable scope

hi
i created a boolean variable with workflow scope. i am using this variable in a for each loop within the workflow. after existing the loop the value becomes default. it is not retaining it’s value outside foreach loop. Can anybody explain why?

Thanks

Hi,

Can you share your workflow file?

Regards,

Hi @MadhuK,

Check the following:

  1. Double check the scope of the variable in question. If you have not renamed the sequences, you can easily get confused with the scope.
  2. Check for duplicate variables
  3. The default value of Boolean variable is False (Even though you explicitly don’t assign it)

Regards,
Nithin

Seems like you have created two variables with same name but in different scope. Select the body sequence of the each loop and then check variable panel. There should be two variables. Delete the one inside the for each scope.

1 Like

Thank you for the response. I defined my variable in sequence scope. No duplicates. Do i need to have my workflow in a flowchart for global scope?

Thank you for the response. But the variable names are unique.

Is it possible to send your workflow file? Also name of the variable that you are facing issue with.

Thank you. We resolved it.

What was the solution?

In studio, check the workflow analyzer,
Rule: ST-NMG-005 - Variable Overrides Variable

This will help you to find duplicate variables and resolve

Hello @MadhuK,

Visit here,

2 Likes

The issue was i had same variables hiding in different scope. Once i deleted the duplicate it was fixed.

Okay :+1:

2 Likes