What is View State in Salesforce | Techila
1227
single,single-post,postid-1227,single-format-standard,ajax_updown_fade,page_not_loaded,,qode_grid_1300,footer_responsive_adv,hide_top_bar_on_mobile_header,qode-content-sidebar-responsive,qode-theme-ver-9.4.2,bridge,wpb-js-composer js-comp-ver-4.12,vc_responsive
 

What is View State in Salesforce

view-state

What is View State in Salesforce

View state of the Visualforce Page comprises of the data which is required to recreate the page during server requests.

 

For Eg:- you have a form which on submit fires a error, Visualforce needs the variable to recreate the form on the UI. These variable sizes constitutes to the View State. Maximum view state holding capacity of Visualforce pages is 135Kb.

 

Best Practices to avoid View State: Now we know what is view state lets discuss about some good practices to avoid reaching the maximum limit of 135 Kb.

 

1) Avoid using multiple forms in the Visualforce Page.

2) Declare variables as Transient.  Transient variables are not saved and therefore not transferred as a part of the view state.

3) Use Custom Settings to store read only Data. Custom settings are a part of Cache and does not constitute to the View State.

4) Refine your SOQL to fetch only the required data needed by the VF Page.

 

Enabling View State View state is an encrypted so native tool of browser won’t be able to show the view state. To enable View State, follow the steps below:

 

1. Go to setup –> Administration Setup –> Manage Users –> Users.

2. Select the user.

3. Click ‘Edit’ button.

4. Check the ‘Show View State in Development Mode’ checkbox.

 

Description: What is View State in Salesforce

 

5. Click ‘Save’ button.

 

Now in the development mode enabled you would be getting an additional tab to view the View state.

Description: What is View State in Salesforce

 

 

Courtesyhttp://www.worldofsalesforce.com/2016/06/what-is-view-state-in-salesforce.html

Author: techila

No Comments

Post A Comment