Activity Forums Salesforce® Discussions What are Methods in Salesforce?

  • Tulika

    Member
    September 22, 2022 at 12:24 pm

    Explaining what are methods in salesforce, is a detailed topic that could not be explained in short here. You can visit this link to have in-depth knowledge of it.

  • Shuvam

    Member
    June 13, 2023 at 10:43 am

    In Salesforce, especially in Apex (the proprietary programming language of Salesforce), methods are blocks of code that perform a specific task. They're like a recipe - you give them ingredients (inputs or parameters), and they do some work (processes the inputs) and then give you a result (return a value).
    There are two types of methods in Apex: instance methods and static methods. Instance methods belong to an instance of a class, and they can access instance variables and instance methods. Static methods, on the other hand, belong to a class instead of an instance of a class, and can only access static variables and static methods.
    Also, you'll often hear about getter and setter methods in Salesforce. These are used in Visualforce and Lightning to retrieve (get) or change (set) the value of an object's attributes.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos