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
vikas  malikvikas malik 

if i reach limit viewstate size 135kb .then how i can i solve that issue in visualforce

Best Answer chosen by vikas malik
Gaurav NirwalGaurav Nirwal

If your viewstate has reach near to 135 kb than you have to show limiited data to user and if some data which you want show only on page and don't need to get back from page then use Transient Keyword before that property.

If you are showing data in table then you have to use pagination.

All Answers

PratikPratik (Salesforce Developers) 
Hi Vikas,

Try to make variables as Transient so they will not count towards the size of view state.

Please refer to Salesforce best practices:
https://help.salesforce.com/apex/HTViewSolution?id=000126956&language=en_US

Hope this will help.

Thanks,
Pratik

P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
Aditya MohanAditya Mohan
Hi Vikas,

You can make your variables transient so that they are not included in the Viewstate. eg:
 
transient Public String accName {get;set;}

Also while doing SOQL queries, do not query unwanted fields. It takes much memory
Gaurav NirwalGaurav Nirwal

If your viewstate has reach near to 135 kb than you have to show limiited data to user and if some data which you want show only on page and don't need to get back from page then use Transient Keyword before that property.

If you are showing data in table then you have to use pagination.
This was selected as the best answer