Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

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

(0) ShareShare
ReportReport
Posted on by
  • joecognizant Profile Picture
    4 on at
    Re: How do I tell if an optional input has been used?
    contains(triggerBody(),'text_1') will return true if the second parameter is present, false if it is not.
  • Chriddle Profile Picture
    7,669 Super User 2025 Season 1 on at
    Re: How do I tell if an optional input has been used?

    @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 😉

  • drewski3420 Profile Picture
    2 on at
    Re: How do I tell if an optional input has been used?

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

  • Chriddle Profile Picture
    7,669 Super User 2025 Season 1 on at
    Re: How do I tell if an optional input has been used?

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

     

    coalesce(optional_value, '')

     

     

  • Manzeela Profile Picture
    11 on at
    Re: How do I tell if an optional input has been used?

    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!

  • luismonteiro Profile Picture
    4 on at
    Re: How do I tell if an optional input has been used?

    Were you guys able to fix/work around this?

  • gwsmith Profile Picture
    4 on at
    Re: How do I tell if an optional input has been used?

    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.

  • Community Power Platform Member Profile Picture
    on at
    Re: How do I tell if an optional input has been used?

    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.

     

  • Community Power Platform Member Profile Picture
    on at
    Re: How do I tell if an optional input has been used?

    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.

  • yashag2255 Profile Picture
    24,442 Super User 2024 Season 1 on at
    Re: How do I tell if an optional input has been used?

    @Anonymous What is your optional input type?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow