Processing unlimited result sets in Apex

In this section, a new Race Analysis page is created to allow the user to view the results of various calculations and simulations applied dynamically to selected race data. Ultimately, imagine that the page allows the user to input adjustments and other parameters to apply to the calculations and replay the race data to see how the race might have finished differently.

For the purposes of this section of the chapter, we are focusing on querying the Race Data object. With the standard row limit of 50,000 records, we can query approximately 5 races' worth of data within the standard Visualforce page execution context. The following changes have been made to the FormulaForce application to deliver this page and are present in the code samples associated with this chapter if you wish to deploy them:

  • A new analyzeData method on the RaceService class has been added.
  • The RaceDataSelector class has been created to encapsulate the query logic.
  • RaceAnalysisController has been created for the Visualforce page.
  • The raceanalysis Visualforce page has been created.
  • A new Race Analysis list custom button has been added to the Race__c object. This button has been added to the list related to Races on the Season record page.

The user can now select one or more Race records from the related list to process as follows:

The next display provides a confirmation of the selected races before starting the calculations. This button invokes the RaceService.analyzeData method and attempts to query the applicable RaceData__c records:

Before we can explore the Visualforce feature to process large result sets, we must create more than 50,000 records. The next section will walk through the steps to achieve this.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.56.114