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
RC_48RC_48 

Displaying apex page message on screen is increasing the view state by around 30Kb.

Hi All,

I have a condition on my visualforce page i.e., If there are no line items for the order and if user tries to click button(Save) , a warning message should be displayed on screen like "Orders without a line item will negatively impact system automation, please add line item before saving". But while I am trying to achieve this, my page size is increasing from 134kb to 162kb. 

If I try to click button(Save) on order having line items, the page size is normal ie.,134kb to 117kb.

Can anyone please suggest me how can I avoid increasing view state on displaying my warning message on screen.


Thanks,
Chaitanya
 
SwethaSwetha (Salesforce Developers) 
HI Chaitanya,
Considering that your scenario needs code inspection and replication for providing a solution, I'd recommend reviewing the best practices for custom controller actions listed in  https://salesforce.stackexchange.com/questions/60691/best-practices-for-custom-controller-actions/60702#60702

https://salesforce.stackexchange.com/questions/4537/how-to-reduce-a-large-internal-view-state-what-is-in-the-internal-view-state

https://help.salesforce.com/apex/HTViewSolution?urlname=View-State-limit-170-exception-root-cause&language=en_US

If this information helps, please mark the answer as best. Thank you