Methods in Salesforce in Hindi

In Salesforce, a method is a block of code that performs a specific task or action. Methods can be used to perform calculations, manipulate data, and interact with the Salesforce platform,

Table of Contents

Previous Sessions

If you missed the previous sessions, please use the below links for the previous sessions

Methods(Behaviours) in Salesforce

In Salesforce, a method is a block of code that performs a specific task or action. Methods can be used to perform calculations, manipulate data, and interact with the Salesforce platform, such as by creating, updating, or deleting records.


					
				

Types of Methods in Salesforce

There are two types of methods in Salesforce:

  1. Instance/Object Methods: Instance methods are associated with an instance(Object) of a class, and can be called on that instance.
  2. Static(Class) Methods: Static methods are not associated with an instance of a class, and can be called on the class itself. Static methods are used to perform actions that do not require an instance of the class.

Constants

In Salesforce, you can define constants using the “final” keyword in Apex code. Constants are variables whose values cannot be changed once they are initialized.


					
				

Hands-On Code


					
				

Assignment

  1. Create an Instance method sum method with different parameters. Note: – Please use the return statement accordingly
    1. sum(1,2)
    2. sum(3,4,6)
    3. sum(3,4,6,4)
    4. sum(3,4,6,5,6)
    5. sum(3,4,6,7,8,8)
    6. sum(3,4,6…)
    7. sum(3,4,6..)
    8. sum(3,4,6)
    9. sum(3,4,6)
    10. sum(3,4,6)
    11. sum(3,4,6)
    12. sum(3,4,6)
  2. Create Class/Static methods for multiple/sub/div.
    1. Sub() – 2, 3, 4, 5, ——- up to
    2. mul() – 2, 3,4 ——
    3. div(23, 45)
    4. module() – 29/25 ~= 4

Full Video

Resources

Amit Singh
Amit Singh

Amit Singh aka @sfdcpanther/pantherschools, a Salesforce Technical Architect, Consultant with over 8+ years of experience in Salesforce technology. 21x Certified. Blogger, Speaker, and Instructor. DevSecOps Champion

Articles: 299

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from Panther Schools

Subscribe now to keep reading and get access to the full archive.

Continue reading