• #9916
    Salesforce | Ajit Ajit #345

    How to use Switch Clause in Apex as it is used in Java or C?

    Can any one suggest me how to use switch clause in apex as it is used in java or c, need to avoid else If ladder?


    Salesforce | Abhinav Abhinav #337

    Apex does not support switch case statements.Use if else if .statements for this. However, Yes formula fields support case syntax but Apex doesn’t.

    Salesforce | Prafull Prafull #207

    Hi Ajit,

    Apex doesn’t support switch clause as of now.. Salesforce will release it next year… So instead of switch case you have to use else if condition..


     Phil #616

    Take a look at my response on https://developer.salesforce.com/forums/?id=906F000000090xKIAQ – this is a typical object-oriented approach. Note that switch statements are really non-OO, from a purist perspective.

    Salesforce | Manish Manish #319

    Apex now supports Switch Statements (from Summer ’18 Release):

    Full answer here : https://developer.salesforce.com/blogs/2018/05/summer18-rethink-trigger-logic-with-apex-switch.html

Viewing 5 posts - 1 through 5 (of 5 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?