I'm running into errors with a simple switch case and can't figure out the problem. I have a choice field in my list called "Approval Status" with 4 choices: Submitted by Division, Approved by HR-Finance, Approved by ELT, and Hired. Screenshot below:
When attempting to run, I get the following error:
What am I doing wrong? When I changed the field just a free text, string field, everything ran fine. Why is this choice field passing it as an 'Object' instead? Looking at a few other posted cases makes me think this should be working as is.
Solved! Go to Solution.
It happens to have an example exactly like yours, just my column name is Depart, as we had a few departments to choose from. Use the "Initialize variable":
Also you dont need to create so many "send emails". Can use just one and at "To" field use the expression:
if(equals(variables('Approval Status'),'Submitted by Division'),'email@example.com',if(equals(variables('Approval Status'),'Approved by HR-Finance'),'firstname.lastname@example.org','email@example.com'))
So for first case, the mail will go to firstname.lastname@example.org, if the choice was "Approved by HR-Finance" the mail will go to email@example.com, all other choices will go to firstname.lastname@example.org.
Modify the expression to your needs.
edit: if I`m not mistaken, if you use the if() expression to send mails, you can loose the switch case entirely. Just make sure you have a column choice in sharepoint list (radio buttons, in my case). Your flow will send mails according to the choice selected in sharepoint
We are excited to announce the launch of Power Virtual Agents Community. Check it out now!
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!