cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Switch case with a choice field errors

Hello,

 

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:

Flow Error.PNG

 

When attempting to run, I get the following error: 

 

Flow Error Message.PNG

 

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. 

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Switch case with a choice field errors

Yep, there you go. “Approval Status” IS an Object.

But, the screen shot also tells us that there is another value sent to you. That is “Approval Status Value”.

So if you swap out “Approval Status” for “Approval Status Value” in your switch statement you should be good.

- Mark

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Switch case with a choice field errors

Please put a Compose action above your switch and put the Approvals Status field in there. Then run it and show us the output from that.

I think it will show an “Object” rather that the value. Is Approval Status a Choice? Or a lookup Column?

And, just to check, there “is” an Approval Staus set on that list item?

Could you also expand out the Output of the trigger event so we can see all the item properties that is sent over in the Flow. That should show what is being sent for Approval Status.

- Mark
Highlighted
Resolver III
Resolver III

Re: Switch case with a choice field errors

Hi @rzaddTDOE

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":

Capture.JPG

 

 

 

 

 

 

 

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'),'test1@test.com',if(equals(variables('Approval Status'),'Approved by HR-Finance'),'test2@test.com','test3@test.com'))

So for first case, the mail will go to test1@test.com, if the choice was "Approved by HR-Finance" the mail will go to test2@test.com, all other choices will go to test3@test.com.

 

Modify the expression to your needs.

Cheers!

 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





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





Highlighted
Frequent Visitor

Re: Switch case with a choice field errors

Hi Mark,

 

Here are screenshots of what you requested. Details of Approval Status FieldDetails of Approval Status FieldFlor Error 2-12-2.PNGFlor Error 2-12-3.PNG

 

Let me know if you need anything else to troubleshoot. Thanks!

Highlighted
Super User
Super User

Re: Switch case with a choice field errors

Yep, there you go. “Approval Status” IS an Object.

But, the screen shot also tells us that there is another value sent to you. That is “Approval Status Value”.

So if you swap out “Approval Status” for “Approval Status Value” in your switch statement you should be good.

- Mark

View solution in original post

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

Top Solution Authors
Users online (6,198)