I have a flow with a variable, varEmailAddresses. In a Apply to Each loop, depending on certain conditions, I build up this varEmailAddresses by concatenating a semicolon and another variable. If the loop conditions are False, then varEmailAddresses never becomes anything at all - it should stay Null (which is my Initialize original value)
At the end of the Flow, I have a condition: if varEmailAddress is not equal to Null, then:
Send an email from a shared mailbox. The BCC is:
substring(variables('varEmailAddresses'), 1, sub(length(variables('varEmailAddresses')),1))
Why? Because I need to remove the first character from that variable, otherwise the variable will be:
;emailaddress;emailaddress;emailaddress
What I'm finding is that I'm currently running my Flow, and during the loop, the Condition is always FALSE. Therefore, varEmailAddresses should be Null at the end, and the Send an Email operation should never execute
However, I'm still getting this error: "The template language function 'substring' parameter is out of range: 'start index' must be non-negative integer and should be less than the length of the string"
Does this mean that, even though the final Condition is FALSE, Power Automate is still trying to evaluate my substring expression? If Yes, then I can understand the error - I'm trying to use substring on a null value.
At runtime, will Power Automate attempt to evaluate an expression even if it is inside an operation which never officially executes, because its wrapper Condition is False? Or is something else going on?