@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 😉
This does not work -- still gives the same error as if you'd used the input directly
This expression checks your optional_value for null and in that case returns the empty string:
coalesce(optional_value, '')
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.
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!
Were you guys able to fix/work around this?
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.
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.
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.
@Anonymous What is your optional input type?
WarrenBelz
146,635
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional