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 / nested if statements i...
Power Automate
Answered

nested if statements in functions

(0) ShareShare
ReportReport
Posted on by 32

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?

Categories:
  • Verified answer
    Manish Solanki Profile Picture
    15,169 Moderator on at

    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

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 426

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard