Hi - how do I check for the existence of a field in the triggerBody? I cannot check for null or empty as this crashes if the property actually doesnt exist. These do not work @equals(triggerBody()['partnerId'], null) or @empty(triggerBody()['partnerId']) if "partnerId" doesnt exist. I need to check as my HTTP request can occasionally not send the required property.
Solved! Go to Solution.
It does not really work for me
This still fails because genius MS Flow tries to evaluate `body('Start_single_approval')['comments']` expression even if you wrap it with if(contains())
if(contains(body('Start_single_approval'), '"comments": '), body('Start_single_approval')['comments'] ,'')
I also have the same issue where the contains function doesn't work checking for the existance of a property in an array. Exactly the same logic (i.e. within an If statement).
I could not find anything that can properly check for properties to exist...
The only ugly workaround is to create 3 scopes:
Created request for a function that check if property exists: https://powerusers.microsoft.com/t5/Flow-Ideas/Add-an-ability-to-check-if-property-exists-in-an-obje...
Please, upvote if you face the same problem.
I haven't tested it yet, but @xilef suggests using '?' approach. Seems promising to me:
if(empty(body('ApprovalByAnyDirector')?['comments']), 'None', body('ApprovalByAnyDirector')?['comments'])
We've updated and improved the layout and uploading format of the Power Automate Cookbook!
Fill out a quick form to claim your user group badge now!
We've given our badges an overhaul and also added some brand new ones!
Learn how to build the business apps that you need.
Find out where you can attend!
Watch & learn from the Power Automate Community Video Gallery!