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

Community site session details

Session Id :
Power Automate - Building Flows
Answered

nested if statements in functions

(0) ShareShare
ReportReport
Posted on by 30

I am trying to set a variable with different message values based on the outcomes of actions in a flow. I am using this if statement in a compose action to do so:

if(equals(body('Run_HQ-0001-DHR_Execute_JAron_python_script_PAD_flow')?['Message'], null),
outputs('Capture_Error_Message'),

if(greater(length(body('Run_HQ-0001-DHR_Execute_JAron_python_script_PAD_flow')?['Message']), 0),
body('Run_HQ-0001-DHR_Execute_JAron_python_script_PAD_flow')?['Message'],
outputs('JAron_Flow_Failed_Message')))

 

The flow runs successfully and does not give me an issue with this syntax, however the output is always empty. Assuming each output has a value (which they do in the flow), why would the output still be blank? Is something wrong with the syntax, or would you suggest it involves one of the outputs?

I have the same question (0)
  • Verified answer
    ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: nested if statements in functions

    Hi @dbgghost 

     

    My guess is the body object does not contain message property. Please try removing all ? from the expression to get the error message:

    if(equals(body('Run_HQ-0001-DHR_Execute_JAron_python_script_PAD_flow')['Message'], null),outputs('Capture_Error_Message'),if(greater(length(body('Run_HQ-0001-DHR_Execute_JAron_python_script_PAD_flow')['Message']), 0),
    body('Run_HQ-0001-DHR_Execute_JAron_python_script_PAD_flow')['Message'],outputs('JAron_Flow_Failed_Message')))

    Another way is to use compose actions for each piece of expressions used in the condition to find the exact error.

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 666 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 382 Moderator

#3
developerAJ Profile Picture

developerAJ 254

Last 30 days Overall leaderboard