• #9916
    Salesforce | Ajit Ajit #217
    Forcetalks

    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?

    Tagged: , , ,

    #9925
    Salesforce | Abhinav Abhinav #316
    Forcetalks

    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.

    #9937
    Salesforce | Prafull Prafull #36
    Forcetalks

    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..

    Thanks

    #26080
     Phil #205
    Forcetalks

    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.

    #29043
    Salesforce | Manish Manish #101
    Forcetalks

    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.

CONTACT US

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

Sending

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 2018 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?