Activity Forums Salesforce® Discussions How to pass id from one method to another method as a parameter in Salesforce?

  • How to pass id from one method to another method as a parameter in Salesforce?

    Posted by Deepak on June 17, 2020 at 2:43 pm

    How to pass id from one method to another method as a parameter in Salesforce?

    Shweta replied 4 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Shweta

    Member
    June 18, 2020 at 2:34 pm

    If you need to access any field in multiple methods in a class, its better to define it in the class, outside any method. e.g.:
    public class SampleClass{
    String userId;
    public SampleClass(){
    // initialize it once in the constructor, use it in any method
    userId= userinfo.getUserId();
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos