Is there a workaround for allowing a flow to run when it's calling a field that has no data populated? I have a sharepoint list with an optional field for a phone number. I need it to send an email and contain the phone number if it's included but since it's an optional field it's not required and not always populated. I still need the email to be sent though. Short of populating the field with a default value and sending that, is there a way to allow the flow to complete without having populated data for optional fields?
Thanks!
According to https://msdn.microsoft.com/en-us/library/azure/mt643789.aspx you can use this expression in a condition block to handle null trigger outputs
@coalesce(trigger().outputs?.body?.property1, 'my default value')
I implemented a test flow with a New Sharepoint item trigger, the following condition
@equals(coalesce(trigger().outputs?.body?.propertyX, 'NULL'), 'NULL')
On the YES branch I included a "Send email" action block for confirmation purposes, leaving the NO branch empty.
In the Sharepoint list definition I included an optional column (propertyX), then I added an iten without filling the optional column.
The flow succeded and I received the confirmation email. But when opening again the flow for editing purposes the following error is displayed:
"unexpected character '?', mode 3"
and no flow block is displayed anymore.
Assuming this is the way to proceed, It will be more user frienly if the condition block offers an option called "not present" and internally converts it to the above expression
I found another thread in this community where @Samuel explains the use of coalesce much much better than my previous post.
As Samuel suggests, a simpler solution than the one I proposed in my previous post can be the following: invoke coalesce in the email body.
@{coalesce(triggerBody()['telephoneproperty'], 'no telephone nr available')}
According to the documentation, coalesce returns the first non-null object in the arguments passed in. Note: an empty string is not null. For example, if parameters 1 and 2 is not defined, this will return fallback: coalesce(parameters('parameter1'), parameters('parameter2') ,'fallback')
Hope this helps
I have over 70 variables that could possibly be null. Do I have to write a coalesce expression for each single variable?
Did you find an anwert to your question and implemented coalesce for all 70 variables?. I am on a same boat and doing so would be tedious and error prone
Maybe an idea:
Having empty values in Select action caused issues so needed a way to use default value in case of empty. This solution worked for me!
if(empty(item()?['Address']),'blank',item()?['Address'])
Hello, @cpierich!
Thank you for posting on the Flow Community Forum! Have you had an opportunity to apply @Lexnnn‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!
Thank you for being an active member of the Flow Community!
-Gabriel
Flow Community Manager
User | Count |
---|---|
78 | |
54 | |
52 | |
42 | |
42 |
User | Count |
---|---|
81 | |
79 | |
75 | |
67 | |
43 |