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

How to pass more than 32 parameters to wrapper class constructor

Hi there,


I am having wrapper class in apex class, i need to pass more than 32 (like 40) parameters to wrapper constructor.

When i was passing more than 32 parameters I am getting you cannot pass more than 32 parameters to wrapper constructor.

Can anyone please tell how can i pass more than 32 parameters?


Any idea or sample please.


Thank you,

Satyendra RawatSatyendra Rawat


Write auto implement properties for all member variable.


what you bind paas as an object like you bind Contact and Account object to wrapper class


public WrapperClass(Contact objCon,Account objAcc)


//bind here value



Here's an idea:


Combine parameters of similar types into arrays and pass the arrays instead of the individual parameters.  For example, instead of:


public myClass( String param1, String param2, String param3 )
   x = param1;
   y = param2;
   z = param3;

you could do this:


public myClass( String[] stringParams )
    x = stringParams[0];
    y = stringParams[1];
    z = stringParams[2];

Calling the constructor would look like this:


myClass anInstance = new myClass( new List<String>{ xValue, yValue, zValue } );

My example uses only three parameters, but you could use this technique to reduce your 40 parameters to some number less than 32.


If this helps, please mark it as a solution, and give kudos (click on the star) if you think I deserve them. Thanks!


-Glyn Anderson
Certified Salesforce Developer | Certified Salesforce Administrator