Type Conversion error on switch statement

Hello All,
I am trying to use a template repeater which has a component ‘Status’ (Integer). I am using the following code to drive the ‘Status’ .


Where I am trying to switch on Sitename (String).
Then I am comparing using If statement in the Switch return, to get a 0 or 1 which drives the Status bit.
Since I am switching on a string, the output (return) of the If statements wont accept 0,1 as output.(it gave me error). When I put the 0 or 1 in quotes it accepts it without any error.

But when I look at the screen , it gives me a type conversion error. See screen shot.

I assume this is the type conversion error on the screen.
And I am wondering how to sort this problem out.
Can anyone please help?

You can simplify your switch statement like this:


forceQuality on a static value of 0 won’t do anything. The important thing to know about the switch/case statements is that they attempt to return the type of the default/fallback value. 1/0 and boolean true/false typecast back and forth pretty much transparently, but in this case to ensure that the final output is an integer you can wrap the entire statement in a toInt.

Thank you.

This seems to have sorted the issue out.