cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cpierich
Level: Power Up

Flow fails when field not populated

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!

6 REPLIES 6
efialtes
Level 8

Re: Flow fails when field not populated

@cpierich

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

 

efialtes
Level 8

Re: Flow fails when field not populated

@cpierich

I found another thread in this community where @Samuel explains the use of coalesce much much better than my previous post.

 

https://powerusers.microsoft.com/t5/Flow-Forum/Is-there-a-way-to-process-null-values-from-CRM-to-Sha...

 

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

 

 

 

 

 

Mack
Level: Powered On

Re: Flow fails when field not populated

I have over 70 variables that could possibly be null. Do I have to write a coalesce expression for each single variable?

dnndev
Level: Powered On

Re: Flow fails when field not populated

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

Lexnnn
Level: Powered On

Re: Flow fails when field not populated

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!

flow empty select.JPG

 

if(empty(item()?['Address']),'blank',item()?['Address'])

Administrator
Administrator

Re: Flow fails when field not populated

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

-Gabriel
Microsoft Power Automate Community Manager
Are YOU a member of your local Power Automate User Group?
Fill out This Form to claim your Community User Group Member Badge!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,557)