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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How do I tell if an op...
Power Automate
Unanswered

How do I tell if an optional input has been used?

(0) ShareShare
ReportReport
Posted on by
Categories:
I have the same question (0)
  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    @Anonymous What is your optional input type?

  • Community Power Platform Member Profile Picture
    on at

    Input type is string.

     

    I found that my flow failed if the input field was empty when I tried to display its value. Of course there should be no visible output but an empty field shouldn't cause a failure. The error message I pulled from the flow history was:

     

    Unable to process template language expressions in action 'Grab_author_comments' inputs at line '1' and column '1953': 'The template language expression 'if(empty(triggerBody()['Comments']),'',triggerBody()['Comments'])' cannot be evaluated because property 'Comments' doesn't exist, available properties are 'entity, text'. Please see https://aka.ms/logicexpressions for usage details.'.

     

    I managed to put in a workaround by initialising a variable using:

     

    if(equals(triggerBody()?['text'],''),' ',triggerBody()?['text'])

     

    This effectively replaces a null content with a space. I also had to do this at the start of the flow. It didn't work when I tried it further down.

     

    Thanks for your interest. It's very much appreciated.

  • Community Power Platform Member Profile Picture
    on at

    I'm still having problems with this. I have two input types; text and email.

    All I'm doing is updating file contents based on the input values entered. I set up all inputs as optional (because they won't all be updated every time) and then check further down the flow to see if they contain anything, but it seems that the triggerbody array is built dynamically and the unused inputs are discarded - so if I check for content on a discarded input it doesn't exist and the flow fails.

    Is there a way to set the inputs as static, so that they exist in the triggerbody array as empty fields even if they're not used? Alternatively is there an expression function I can use to see if a triggerbody array element actually exists before I try to read it?

    Thanks.

     

    As an update. I've tried loading the triggerBody object into a compose card and checking for the input entries there. I can then tell if my input has been used (by whether it's there or not). I assumed that I could then use an if() expression to read it's value only if it existed in the compose output, but alas, if() expressions are evaluated in full so any reference to the missing value fails the flow again.

     

    The answer is to have static fields that contain empty elements if an input isn't used. I can't imagine why they're dynamic in the first place. I can't see any benefit to it. There's no way to use optional inputs when you can't tell if they've been used or not without trying to read them and thus failing the flow.

     

  • gwsmith Profile Picture
    6 on at

    I'm having this problem myself.  I don't know what Microsoft is thinking, allowing you to put in optional fields that actually must be mandatory.  I think a programmer somewhere needs to be fired.

  • luismonteiro Profile Picture
    4 on at

    Were you guys able to fix/work around this?

  • Manzeela Profile Picture
    11 on at

    I was having the same issue and found out that you can check it inside condition if it is empty or not so you know if it has been used or not.

    Manzeela_0-1679877001724.png

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    This expression checks your optional_value for null and in that case returns the empty string:

     

    coalesce(optional_value, '')

     

     

  • drewski3420 Profile Picture
    2 on at

    This does not work -- still gives the same error as if you'd used the input directly

  • Chriddle Profile Picture
    8,436 Super User 2025 Season 2 on at

    @drewski3420 What does not work? The null check with coalesce works fine.

    If you want a solution for your problem, you should tell us about it 😉

  • joecognizant Profile Picture
    4 on at
    contains(triggerBody(),'text_1') will return true if the second parameter is present, false if it is not.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard