You need to sign in to do that
Don't have an account?
Michael M
Maximum view state size limit (170KB) exceeded error
Hello, I am working on a VF page, on which users can upload files. After clicking save, I am getting shown a screen with this message:
Maximum view state size limit (170KB) exceeded. Actual view state size for this page was 1,006.033KB
Any idea how I can stop this error message? The strange thing is that the file seems to be getting uploaded anyways, so I'm not sure what to do with that message.
Maximum view state size limit (170KB) exceeded. Actual view state size for this page was 1,006.033KB
Any idea how I can stop this error message? The strange thing is that the file seems to be getting uploaded anyways, so I'm not sure what to do with that message.
You're basically trying to store every record in the database in the view state. Check about dynamic queries (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm) and this will greatly improve your code's performance and allow you to avoid view state size errors, heap limit exceptions, CPU timeouts, too many query rows, etc.
Check below reference for debugging size limit error.
https://help.salesforce.com/articleView?id=000321547&type=1&mode=1
https://help.salesforce.com/articleView?id=000323828&type=1&mode=1
Hope this helps...
Thanks,
All Answers
You're basically trying to store every record in the database in the view state. Check about dynamic queries (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm) and this will greatly improve your code's performance and allow you to avoid view state size errors, heap limit exceptions, CPU timeouts, too many query rows, etc.
Check below reference for debugging size limit error.
https://help.salesforce.com/articleView?id=000321547&type=1&mode=1
https://help.salesforce.com/articleView?id=000323828&type=1&mode=1
Hope this helps...
Thanks,
Once the file is submitted in apex you can null the file or Attachment from class. This will keep the view state.
Thanks,
Maharajan.C