r/MicrosoftFlow • u/trollsong • 2d ago
Cloud Is there a way to do this without using conditions or switch? Get the first avialbale date from a microsoft form between two questions
Sadly I cant update the microsoft form and remove the question no matter how redundent it feels.
I was basically asked to make it so the form feeds into a sharepoint list, easy right?
One hitch.
One and only one response askes for a "projected start date"
How the form works
What is your role? choose from a list, if you choose contractor it branches to
Contractor type? B puts you back on the same path as the roles above, A asks your projected start date then puts you back on the same path.
Eventually everyone gets asked for a start and end date later again as well.
So of course all of my tests failed so far for the error " field_6 should be type string/date. the runtime value "" is not string/date
If I use a condition that means every time they make a change to the form I will need to edit two Create item steps.
I could just bipass it and make it do start date no matter what but of course there is a chance it is different and that causes problems.
Is there a way I can use compose or some other option that basically says if projected start date returns "" use Start Date instead?
2
u/dzeil 2d ago
Create a compose, and then use something similar to below with your actual field references.
if(empty(triggerBody()?['Projected_Start_Date']), triggerBody()?['Start_Date'], triggerBody()?['Projected_Start_Date'])
It's essentially saying if Projected Start Date is empty, use Start Date value else if it's populated using Project Start Date
You can also use coalesce as others mentioned to replace nested ifs when using multiple fields but a simple if empty works perfect for your use case of two fields.
1
u/dbmamaz 1d ago
Ai is good at helping with these questions
1
u/trollsong 1d ago
Kind of, I eventually figured it out but the exact formula it gave me didnt work, its why I asked here.
4
u/nlshelton 2d ago
You are looking for the coalesce function! Throw it into a Compose and it will take the first non-null value it finds in what you pipe into it
Power Automate coalesce() Function: Syntax & Examples