What is view state error in Salesforce
Author
August 23, 2016
View State: As the name suggests, it is an error of View State. Maximum view state size limit (135KB) exceeded is the error message pertaining to View State error and here follows a brief detailing of the issue.
View state holds the state/size of the visual force page that includes the components, field values, and controller state. This is important in the light that salesforce provides only a standard size of 135kb for any individual page. If the size of a particular page exceeds 135kb, the page will throw a view state error.
A screenshot showing a view state error in salesforce
To check the view state of a visual force page you have to make sure that Show View State in Development Mode checkbox in the User Layout is checked.
You can access this setting from: Setup-> Manage User-> User-> Edit (on a particular user)-> Show View State in Development Mode
Pranshu Goyal, Director of Products at Mirekta, states: “We envision DSM to be used by every small to a medium-sized organization dealing with bad data and want to get rid of duplicates easily with no cost. We have faced issues dealing with duplicates in our organization. That inspired us to make a solution that is not only simple to use but can be used widely to make the organization’s data clean to make them more efficient and productive. We want DSM to be a solution for every organization looking for duplicate management capability better than the Salesforce out-of-the-box solution with no additional cost.”
How to reduce View State:
1. Use the transient keyword: The simplest and the most logical way is to keep the size of the VF page as small as possible. For this purpose, Transient Variables are used as these do not store the values permanently, these variables just hold the values temporarily and therefore not stored in View State. Declaring variables as transient reduces view state size.
An example showing how a transient variable is declared: transient String name;
2. Refine your SOQL: Reduce the number of records displayed on a page by refining SOQL. The use of AND statements, WHERE clause in SOQL, removing NULL results can help assure that only required data comes back from SOQL.
3. Minimize the Number of Forms on a Page: We should use <apex:actionReagion> instead of using two <apex:forms>.
Each form on your page will have its own copy of view state. Instead of having multiple forms on a page, have a single form and use <apex:actionRegion> to submit portions of the form.
This will make sure only a single copy of the view state is associated with that VF page instead of two copies.
Eg:
// Using two <apex:form>
<apex:page controller=”ApexController”>
<apex:form>
<apex:commandButton action=”{!objectFirstMethod}” value=”First Object”/> </apex:form>
<apex:form>
<apex:commandButton action=”{!objectSecondMethod}” value=”Second Object”/>
</apex:form>
</apex:page>
// Using <apex:actionRegion>
<apex:page controller=”ApexController”>
<apex:form>
<apex:commandButton action=”{!objectFirstMethod}” value=”First Object”/>
<apex:actionRegion>
<apex:commandButton action=”{!objectSecondMethod}” value=”Second Object”/>
</apex:actionRegion>
</apex:form>
</apex:page>
4. Use Custom Setting: Use custom setting to store large quantities of read-only data instead of custom objects. Accessing custom settings is faster than accessing custom objects since custom settings are part of application’s cache and does not require a database query to retrieve the data unlike custom objects.
5. Use <apex:outputLink> : Instead of using <apex:commandLink> or <apex:commandButton> components, Use <apex:outputLink> because <apex:commandLink> or <apex:commandButton> requires to be included inside a <apex:form> component unlike <apex:outputLink>.
Recent Posts
-
Salesforce 2025 Game-Changing Trends You Need to Know28 Jan 2025 Blog
-
Agentforce 2.0: Everything You Need to Know About the Latest Update22 Jan 2025 Blog
-
The Ultimate Guide to NetSuite Development: Tools and Techniques10 Jan 2025 Blog
-
How Salesforce Nonprofit Cloud Transforms Fundraising Strategies10 Jan 2025 Blog
-
The Impact of Salesforce Development Partners on Small and Medium Businesses08 Jan 2025 Blog
-
Key Questions to Ask When Hiring a NetSuite Development Partner08 Jan 2025 Blog
-
Salesforce Agentforce Demystified: Your Essential Guide08 Jan 2025 Blog
-
Salesforce and NetSuite Integration: Driving Business Efficiency with Precision06 Jan 2025 Blog
-
Everest Group has positioned Mirketa as an Aspirant in the report24 Dec 2024 Press Release
-
Salesforce Einstein20 Dec 2024 E-Book
-
Order to Cash Cycle with NetSuite20 Dec 2024 E-Book
-
Empower Your Marketing Strategy with Salesforce Marketing Cloud's Automation Studio Activities13 Dec 2024 Blog
-
Salesforce CPQ for Subscription-based Businesses10 Dec 2024 Blog
-
Unleashing the Magic of Einstein Prediction Builder10 Dec 2024 Blog
-
Customized Templates and Branding with Salesforce Experience Cloud10 Dec 2024 Blog
-
Unleashing the Power of Real- Time Reports and Dashboards in NPSP10 Dec 2024 Blog
-
Top 4 Salesforce Automation Tools in 202409 Dec 2024 Blog
-
Salesforce Service Cloud Implementation: The Ultimate Guide09 Dec 2024 Blog
-
Salesforce CRM Implementation Partner Enhancing Automation in Healthcare09 Dec 2024 Blog
-
Shorten Your Sales Cycle in 8 Steps: Salesforce CPQ Implementation Guide09 Dec 2024 Blog
-
Overcoming Top 5 Common Sales Challenges With Salesforce Revenue Cloud06 Dec 2024 Blog
-
Empowering Sales Teams with Einstein: 5 Proven Methods to Drive Sales Success05 Dec 2024 Blog
-
Mirketa Recognized by NetSuite as Summer 2024 Alliance Partner Spotlight Award Winner04 Dec 2024 Blog
-
Salesforce Agentforce: Revolutionizing AI with Autonomous Agents03 Dec 2024 Blog
-
How to send information from one Salesforce Org A to another Org B using Salesforce Integration?30 Nov 2024 Blog
Categories
Featured by



