Avoid switch case failure with coalesce in Power Automate.
Hello Guys,
In our previous blog we have seen how to use Switch Case with Microsoft Flow. Today we will see how we can avoid switch case failure using coalesce function. But before If you are new to MS Flow then please read my this blog.
Do follow us to know more about Dynamics and Power Platform. Also if you like our blog then please comment and share this blog with your friends.
we will be working with same flow which we have used in our previous blog.
As you can see we have our flow. we can run it by providing Entity Name as input and it will run successfully. What if we don't provide any input and click on run. So let's check it. We need to do some changes in first step.
Expand the first step and click on three dots and select Make the field optional. Save the changes and run this flow without providing an input.
As you can see in above image our flow got failed at switch case step. It got failed because the value which was passed to the switch case for evaluation is blank. Here we are passing value by taking input but there are many situation where we are retrieving this value first from another process and passing it to the next step. It is possible in some scenario it can be blank or null. To avoid this failure we have to use coalesce function.
Expand the switch step and make the changes as below.
coalesce(triggerBody()?['text'],'Unknown')
Save the changes and run the flow again without providing any input.
As you can see it ran successfully without any failure.
Hope it helps...
Comments
Post a Comment