function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dnyaneshwar MandwadeDnyaneshwar Mandwade 

Please anyone help me, how can i return multiple object data from single apex class.

Best Answer chosen by Dnyaneshwar Mandwade
Team NubesEliteTeam NubesElite
Hi Dnyaneshwar,
One way is to create wrapper class, for example:
public class wrapperClass{
Integer int;
String str;
Account acc;
}
And use this class as a return value of your method:
public static wrapperClass methodToReturnWrapper(){

    wrapperClass wc = new wrapperClass();
    //here you can fill in wrapper with values you want, like wc.int = 1
    return wc;
}

Thank You
www.nubeselite.com

Developement | Training | Consulting

Please mark this as solution if your problem resolved.

 

All Answers

Team NubesEliteTeam NubesElite
Hi Dnyaneshwar,
One way is to create wrapper class, for example:
public class wrapperClass{
Integer int;
String str;
Account acc;
}
And use this class as a return value of your method:
public static wrapperClass methodToReturnWrapper(){

    wrapperClass wc = new wrapperClass();
    //here you can fill in wrapper with values you want, like wc.int = 1
    return wc;
}

Thank You
www.nubeselite.com

Developement | Training | Consulting

Please mark this as solution if your problem resolved.

 
This was selected as the best answer
Steve Blackwell 2Steve Blackwell 2
Credit for the answer above from Nubeselite actually goes to Marek Kosar_ in this thread from 2016 that they copy-pasted his answer from and gave no credit back to: https://developer.salesforce.com/forums/?id=906F0000000MLuwIAG