+ Start a Discussion
arobharobh 

swich-case statement

Does salesforce support swich-case statement and if it is then pls help me with the correct syntax.

Jerun JoseJerun Jose

Apex does not support switch case statements.

 

Use if .. else if .. statements for this purpose. However, formula fields support case syntax, but it eventually compiles into an if ... else if format

acousticacoustic
Depending on the requirements you may be able to solve it by using Case formula in a workflow field update or formula field (workflows have larger compile size than field formulas) and then use that field in a trigger to fire off the remaining logic. I did it with the Case priority field and it works great with just three lines of code