Maximum view state size limit exceeded

  • 1
  • Problem
  • Updated 4 months ago
  • In Progress
I have a Skuid page I am using with Salesforce where I'm doing a csv file upload then comparing Opportunities and updating fields on the Opportunity (i.e. dates, stage, etc).  The file has grown and now I am getting the error:  "Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 157.109KB" when try to upload a document.

There is a writeup on what needs to be done to fix it but I believe this is something Skuid would need to do on the platform (https://salesforce.stackexchange.com/questions/53112/maximum-view-state-size-limit-135kb-exceeded)

Has anyone come across this and/or is there a fix that's known to resolve this issue?

Thank you!
Photo of Ali Jenan

Ali Jenan

  • 120 Points 100 badge 2x thumb

Posted 4 months ago

  • 1
Photo of Stephen Sells

Stephen Sells

  • 17,326 Points 10k badge 2x thumb
I'm fairly certain you need to set the "readonly" attribute on their Visualforce page to true, like we do in basically every example on this page in our documentation.

Also, here's the applicable Salesforce documentation, which actually explains what that property does. I believe you might want to reach out to your salesforce admin for more questions.
Photo of Ali Jenan

Ali Jenan

  • 120 Points 100 badge 2x thumb
Stephen... that doesn't seem to work.  Below is the very simple code that is being used and I still get the error after adding the Readonly piece.

<apex:page readonly="true" standardController="Application_Import__c"
  extensions="skuid.Redirects"
  action="{!redirect}?objectType=Application_Import__c&actionType=View"> 
</apex:page>

I also thought it may be due to the number of blank lines (there is a blank line between each row in the csv) and I took those out but increased the number of rows to about 5,000 and now I am getting the following error...

Apex CPU time limit exceeded
Error is in expression '{!validateFile}' in component <apex:commandButton> in page skuid:import: (skuid)

We (OpenGate) are a partner of yours (Skuid) so I don't see a need to get my Salesforce Admin involved.  I have already had this issue looked at by our developers here and I was hoping this was something you could help me with.

Please advise on what you recommend to try next.
Photo of Stephen Sells

Stephen Sells

  • 17,326 Points 10k badge 2x thumb
I'm sorry. Have you tried readOnly ? It is case sensitive.
Photo of Ali Jenan

Ali Jenan

  • 120 Points 100 badge 2x thumb
That doesn't fix the problem.  Same error.

It seems when I cut down on the blank lines between the records and keep the number of lines (records) that I am uploading down around 2300 it works fine.  Seems like a small number to me though.  I would assume we could get more in there than that.

Any thoughts on the link I sent in my first request above?

Any other help would be greatly appreciated.
Photo of Stephen Sells

Stephen Sells

  • 17,326 Points 10k badge 2x thumb
Hey Ali,
1. Error 1, `Maximum view state size limit (135KB) exceeded` was resolved by putting the page into readOnly mode
2. Error 2, `Apex CPU time limit exceeded` is a different limit that indicates it took longer to process the rows than Salesforce allows for processing (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm), and Salesforce canceled the process
Reducing the number of rows in a single import will help with error 2, but we recognize it’s not ideal. Have you considered the Salesforce Data Import Wizard (https://help.salesforce.com/articleView?id=data_import_wizard.htm)? It has seen a lot of improvements since we originally built the Skuid importer tool.
Photo of Ali Jenan

Ali Jenan

  • 120 Points 100 badge 2x thumb
Error 1 was not resolved when I put the page in readOnly mode.  Error 1 was resolved when I took out records to reduce the import regardless of the readOnly parameter.

Is there anything we can do to prevent the Error 1 as the import file grows?