I have a very complex flow with 70 branches formed from nested switch cases and need a way to populate the switch case string from a variable declared upstream in the flow. To date I have managed this manually by typing the string literals into every case (slow) but this is intolerant to changes upstream.
Image 1: this is what I have x 70:
Image 2: this is what I need to allow changes in case to be managed for all forks in the flow:
But variables('keywordType') is being parsed as a string literal not a variable reference. Appending '@' throws the following error:
'The template action 'my switch name' at line '1' and column '9117' is not valid: the value '@@variables('keywordType')' specified for 'case' property in switch case 'my case name' contains expressions that are not supported. Only a literal of type string or interger or a '@parameters()' expression can be specified for the 'case' property.' complete with Microsoft Typo.
In other words the '@' is appended by the system, but still deemed a string literal.
Is there some syntax I'm missing here? Or is it not possible to reference a variable in the case of a switch case? That would be crazy I would have thought, particularly as the error states: '@parameters()' expression can be specified .
Any clue greatly appreciated!
Looking at the error it does say that the expression can be used but its not allowing yours to be used. It looks like it should work but I'm personally not sure why its not. This might be something that Microsoft will need to delve a bit farther into. I'll pass this on but I would also encourage you to open a ticket on this if you would like to track this. I'll include a link below if you would like to do so.
If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so: https://docs.microsoft.com/en-us/power-platform/admin/get-help-support
Community Support Team _ Alex Rezac
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Any luck with getting this to work? I also need to use a variable in a case for a switch and can't get it to work. Getting the same error as you posted above, @HydrogenUtility .
No. It doesn’t work. Final response from MS variables are not supported in switch statements.
Documentation is not up to date and the error message is generic.
I completely redesigned my flow and eliminated switch altogether opting instead to populate all variables based on a single top level variables and runtime loading of an excel table.
Turned out to be a much better solution and entirely scalable.
Good luck on your flow building.
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.