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
GeekyAkshayGeekyAkshay 

Is it possible to just load data in Apex Variable and dont count it against Visualforce Viewstate ?

I want to load bulk data in Apex Variable (Data more then 135KB), But doesnt want to count it against Visualforce Viewstate, otherwise it will break.

public List<User> ContactListTemp {get;set;}

Above is the variable declaration, when i load data into it, its still gets count under viewstate.(Screenshot below)

User-added image

 

Thanks

SandhyaSandhya (Salesforce Developers) 
Hi,

You can declare variables as Transient.Refer below blog which has sample code for the same.

https://www.jitendrazaa.com/blog/salesforce/introduction-to-view-state-in-visualforce/
 
https://developer.salesforce.com/docs/atlas.en-us.salesforce_visualforce_best_practices.meta/salesforce_visualforce_best_practices/pages_best_practices_perf_code_view_state.htm
 
   Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya