web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Will an expression be ...
Power Automate
Unanswered

Will an expression be evaluated even if the condition is NO ?

(0) ShareShare
ReportReport
Posted on by 107

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?
Categories:
  • Mira Ghaly Profile Picture
    11,415 Moderator on at

    @isaac1 

    Before sending your email you can add a condition as  below and yes it is still trying to evaluate it but you share steps would be easier to identify the issue

    Mira_Ghaly_0-1617920519458.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 377

#2
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 130

Last 30 days Overall leaderboard