Question

I am running into a strange problem wherby I have a (quite complicated) VisualForce page that I pass a couple of parameters to when running. This page runs fine.

Example URL: https://force.com/apex/medicalforecast?t=SUMMARY&y=2013

However, if I embed it into another simple visualforce page with the following code I get a "System.LimitException: Too many query rows: 50001" error.

<apex:page sidebar="false">
    <apex:include pageName="MedicalForecast" />
</apex:page>

Example URL: https://force.com/apex/Forecast?t=SUMMARY&y=2013

Can anyone explain this behaviour? Is there additional queries run when embedding one VisualForce page into another?

Thank you

Was it helpful?

Solution

Read http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_get_request.htm

especially that part:

  1. The constructor methods on the associated custom controller or controller extension classes are called, instantiating the controller objects.
  2. If the page contains any custom components, they are created and the constructor methods on any associated custom controllers or controller extensions are executed.

So in the first initial request the constructors (and getters) of main page and all embedded pages/components will fire to render the initial state. That means it's all one transaction, one context and the 50K rows limit is shared across them.

Maybe you can annotate your pages with readonly="true" or try to make the constructors slim (not wasting too many queries). Put a "fetch data" button & action method - user will have to make 1 more click but this will count as separate action = fresh 50K rows limit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top