Showing results for 
Search instead for 
Did you mean: 

Ability to 'Initialize variable' at any level

"The operation 'Initialize variable' can only be used at top level."




It sometimes makes sense to be able to initialize a variable within a condition.  Otherwise, we have to initialize variables at the start of a flow, and they're not always going to be set - especially in more complicated flows with lots of conditions (especially nested ones).  Can we please change it so that a variable can be initialized at any level in the flow.



Status: New
Advocate I

I'm new to Flow, but 100% agree. My first flow has a page and a half of variables. Some used as constants; some used as text buffers that will be built up over the course of the flow; some are counters, incremented in loops.


Compose can create arbitrary objects, but they appear to be read-only. Or at least cannot be used with data actions such as append string action or increment integer


One would have thought that the control activity Scope would at least live up to its name. Alas, you cannot create variables that have scope of only the Scope.


I'm probably missing something, and perhaps should learn how to better leverage Compose. Pointers are appreciated.

New Member

Mid 2020 and this feature is not available. Not sure if this might be considered a bad practice to have a variable initialized for one of your "fork" flows vs initialized at the top for the entire logic app. My thinking is that I have an exception scenario and it happens for 0.01% of runs and only then I need alternative message to be send and I need to initialize those variables, why would I want them initialized every time the app runs, though there is not yet a solid reason to split it into multiple apps.

Regular Visitor

i want to use a variable of yes/no to trigger sending an email 1 time, it is on a doc that has an upload versioning approve, so i can't change a field, as that would change the Approve Status back to pending.  Then need to be reapproved after changing the field for notice sent.  If no, it sends email then changes to yes, then i look for only no to send email, after email sent, change to yes, then it stops sending.

New Member

I agree with this.  Initializing a variable should be able to be set in any scope.  Or more accurately, set variable should also initialize the variable if it does not currently exist.  This would allow better clarification when designing flows as well as reducing API calls for conditions that don't need to utilize variables.  Such as in the case of rejected approvals.

Regular Visitor

2022 now. So... did Microsoft just completely forget about this altogether???