I am trying to setup a switch statement to compare category numbers 1-15 to send out seperate e-mails depending on category # listed on the sharepoint list, but for some reason I keep getting the error that switch only accepts int/str and the value presented is a float.
Anyone know how i can get around this?
Solved! Go to Solution.
You can use expression to convert. It is a nested expression, the first one converts to a string, the second converts string to a int, if you are just using it in the switch and doesnt matter if its a number just string string(insertvalue)
int(string(insertvaluehere))
You can use expression to convert. It is a nested expression, the first one converts to a string, the second converts string to a int, if you are just using it in the switch and doesnt matter if its a number just string string(insertvalue)
int(string(insertvaluehere))
HI @Anonymous
Indeed that's quite annoying, but it's the behavior when fetching the number.
I replicated your issue. It's this what you're getting correct?
There's no way in Power Automation to convert from float to int, so we have to work our way around the issue. And believe me, this is a big workaround, but it works.
To solve this add a compose step before and do the following:
int(split(string(body('Get_item')?['increment']),'.')[0])
In my case, the column in SharePoint is called increment, but please replace it with the name of your column. The same for the action name ('Get_item').
I know, right? Crazy. Let's break this down into steps:
You'll get something like this.
The run is now successful:
Does all of this make sense to you. If not please let me know and I'll explain further.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Cheers
Manuel
no need for extra steps you can just include the expression in the switch 🙂
Hi @Anonymous
I fully understand :). This was something that happened to me in the past and drove me crazy in the past.
You can also like @Gristy mentioned, and put all in the switch. This is a question of preference. I like to have individual steps so that I can debug stuff while it's running, but both of them work. Thanks @Gristy for the suggestion.
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Cheers
Manuel
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
40 | |
36 | |
35 | |
34 | |
27 |
User | Count |
---|---|
39 | |
38 | |
33 | |
31 | |
25 |