+ Start a Discussion
cduncombe44cduncombe44 

View State Size Exceeded

I have a somewhat interesting problem.  I have a VF page and a controller that I came up with as a solution to not being able to queue tasks, basically, its just a big list of processes (custom object) that are all assigned to me.  The user can then go in, and take ownership of them, and they are removed from this master list or queue.  The page seems to work great for me and the other sys admin, but when we try to test it logged in as our end users we get the error

 

Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 190.75KB

 

I dont understand why this is only happoening to that profiel, and doesnt give the error when I use the page.  Anyway, here is the code.  I'm not sure where I could use the transient keyword to help or if my SOQL could be improved, but any help woul dbe greatly appreciated

 

 

VF Page

<apex:page controller="InsuranceCampaignMasterController">

<apex:sectionHeader title="Insurance Profile Campaign" subtitle="Master List"/>
	<apex:form >
	<apex:outputpanel id="container">
	<apex:outputpanel id="table">	
	<apex:pageblock >
	<apex:pageBlockButtons location="top">
		<apex:commandLink action="{!viewAll}" value="View All" styleClass="btn" style="text-decoration:none" id="all" rerender="table,mine,container"/>
		<apex:commandLink action="{!viewMine}" value="View Mine" styleClass="btn" style="text-decoration:none" id="mine" rerender="table,mine,container"/>		
	</apex:pageBlockButtons>
	
	<apex:pageBlockTable value="{!myProcesses}" var="pro" style="width:100%; border:1px solid #D4DADC;">
		
		<apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter == 'Show All'}">
        	<apex:commandLink action="{!takeOwnership}" value="Take Ownership" styleClass="btn" style="text-decoration:none" rerender="table">
            	<apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
        <apex:column style="width:120px; padding-top:10px; padding-bottom:10px; text-align:center;" rendered="{!Filter == 'Show Mine'}">
        	<apex:commandLink action="{!setStep}" value="View" styleClass="btn" style="text-decoration:none" rerender="table,mine">
            	<apex:param name="proId" value="{!pro.id}" />                          
            </apex:commandLink>
        </apex:column>
		<apex:column headerValue="Contact" value="{!pro.Contact__c}"/>
		<apex:column headerValue="Reason for no Insurance" value="{!pro.Contact__r.Reason_for_no_Insurance__c}"/>
		<apex:column headerValue="Street Address" value="{!pro.Contact__r.MailingStreet}"/>
		<apex:column headerValue="City" value="{!pro.Contact__r.MailingCity}"/>
		<apex:column headerValue="Phone" value="{!pro.Contact__r.Phone}"/>	
	
	</apex:pageBlockTable>
	</apex:pageblock>	
	</apex:outputpanel>
	
	<apex:outputPanel id="mine">
	<apex:pageBlock title="Complete Insurance Profile for {!con.Name}" rendered="{!showStep == true}">	
	<apex:pageBlockTable value="{!MyStep}" var="step" style="width:100%; border:1px solid #D4DADC;" rendered="{!Filter == 'Show Mine'}">
		<apex:column headerValue="Name" value="{!step.Name}"/>
		<apex:column headerValue="Assigned To" value="{!step.Assigned_To__c}"/>
		<apex:column headerValue="Status" value="{!step.Status__c}"/>		
		<apex:column headerValue="Complete" >
			<apex:outputtext value="{!step.Complete_Step_From_Process__c}" escape="false"/>
        </apex:column>
		<apex:column headerValue="Log Activity" >
			<apex:outputtext value="{!step.Log_Activity_From_Process__c}" escape="false"/>
        </apex:column>
		<apex:column headerValue="Create Task" >
			<apex:outputtext value="{!step.Create_Task_From_Process__c}" escape="false"/>
        </apex:column>	
		<apex:column headerValue="Completed By" value="{!step.Completed_by__c}"/>
		<apex:column headerValue="Date Completed" value="{!step.Date_Completed__c}"/> 		
	</apex:pageBlockTable>
	</apex:pageBlock>
	
	<apex:pageBlock title="Activities" rendered="{!showStep == true}">
	<apex:pageBlockTable value="{!stepActivities}" var="act" style="width:100%; border:1px solid #D4DADC;" rendered="{!stepActivities.size != 0}">
		<apex:column headerValue="Date" value="{!act.ActivityDate}"/>
	    <apex:column headerValue="Owner" value="{!act.OwnerId}"/>
	    <apex:column headerValue="Type" value="{!act.Subject}"/>
	    <apex:column headerValue="Subject" value="{!act.Navigator_Subject__c}"/>
	    <apex:column headerValue="Description" value="{!act.Description}"/> 
	</apex:pageBlockTable>
	<apex:outputText value="No Activities Recorded Yet" style="font-weight:bold;font-size:large;" rendered="{!stepActivities.size==0}"/>
	</apex:pageblock>
	</apex:outputPanel>
	
	</apex:outputpanel>
	</apex:form>

</apex:page>

 Controller

public with sharing class InsuranceCampaignMasterController {
	
	List<Process__c> myPros;
	List<Task> acts;
	Process__c selectedProcess;
	Public String Filter {get;set;}
	Public boolean showStep {get;set;}
	Public Process_Step__c step;
	Public Contact con {get;set;}    	
	

	public InsuranceCampaignMasterController() {
		myPros = new List<Process__c>();
		acts = new List<Task>();
		selectedProcess = new Process__c();
		step = new Process_Step__c();
		Filter = 'Show All';
		ShowStep = false;
		con = new Contact();
	}

	public List<Process__c> getMyProcesses() {
		
		if(Filter == 'Show All') {
			myPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
							Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__r.Name = 'Chris Duncombe'];
		} else {
			myPros = [Select Id, Name, Process_Owner__r.Name, Contact__c, Contact__r.MailingStreet, Contact__r.MailingCity, Contact__r.Phone,
				Process_Template__r.Name, Progress__c, Contact__r.Reason_for_no_Insurance__c From Process__c 
							Where Process_Template__r.Name = 'Insurance Profile Campaign' and Process_Owner__c =: userinfo.getUserId()];
		}	
		
		return myPros;
	}
	
	public void takeOwnership() {
		
		selectedProcess = [Select Id, Name, Process_Owner__c From Process__c 
										Where Id =: system.currentPageReference().getParameters().get('proId')];
		step = [Select Id, Name, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		
		selectedProcess.Process_Owner__c = userinfo.getUserId();
		step.Assigned_To__c = userinfo.getUserId();
		update selectedProcess;
		update step;
		
	}
	
	public void setStep() {
		
		showStep = true;
		selectedProcess = [Select Id, Name, Contact__c, Process_Owner__c From Process__c 
										Where Id =: system.currentPageReference().getParameters().get('proId')];
										
		step = [Select Id, Name, Process__c, Complete_Step_From_Process__c, Log_Activity_From_Process__c, Create_Task_From_Process__c, Status__c,
								Completed_By__c, Date_Completed__c, Assigned_To__c From Process_Step__c Where Process__c =: selectedProcess.id];
		con = [Select Id, Name From Contact Where id =: SelectedProcess.Contact__c];
		
	}
	public process_Step__c getMyStep() {
		return step;
	}
	
	public List<Task> getStepActivities() {
		acts = [Select Id, Subject, Navigator_Subject__c, ActivityDate, Description, WhoId, OwnerId, WhatId From Task Where WhatId =: step.id];
		return acts;
	}
	
	public void viewMine() {
		Filter = 'Show Mine';
		showStep = false;
		getMyProcesses();
	}
	public void viewAll() {
		Filter = 'Show All';
		showStep = false;
		getMyProcesses();
	}
	

}

 

Thanks again,

 

Chris

colemabcolemab

I would start with using the view state inspector to determine how the view state is being allocated.  Then you will know what item(s) to limit, remove, or otherwise make transient.

mppmpp

Hi!

 

I recently came over the same behaviour. While I am logged in as administrator and have view state inspector enabled I don't see any view state errors there are no problem. As soon as I am logged in as regular user I am getting view state size error.

 

Did you succseed to find solution?