Tuesday, 15 September 2015

Salesforce Pagination Methods, Procedures, Pros and Cons of each

What is Pagination in Salesforce?

Pagination in Salesforce is a process of dividing large amount of records from Salesforce database into multiple pages with each page at a predefined records size and presenting it to user in a page by page display. User will navigate through the pages using the navigation buttons.

What is Salesforce List Views?


Salesforce allows to create list views to see a specific set of records of all Standard Objects and all custom objects provided if objects are/can be exposed via custom tab.
For Example,
Standard Objects: Opportunity, Contacts, Accounts etc.,
Custom Objects: All (if you expose via custom tabs)

The list view criteria can be modified using the filter criteria and filter expressions. Access to these list views can be controlled by sharing the view to specific group of users or to all users. In addition, each user can also create and have their individual view not shared to others.


However, the standard list views cannot be used for most of our customization's in Visual force (refer next section).


What makes Pagination in Salesforce Important?


Standard salesforce list view pagination cannot be used in the following few scenarios,

    - Display all records chatter followed by myself in a table

    - Display all Opportunities that has a specific Product in its line item list
    - Display a specific set of records (based on criteria), that will allow user to select individual records and to some further processing/action
    - Display records in a table and allow user to change filter criteria dynamically

Hence visual force custom pagination becomes essential


Why Pagination in Salesforce is difficult?


Implementing custom pagination on a visual force is certainly not easy and it comes through practice. Developer has to win all the below limits when building pagination in order to make a successful pagination design.

Governor Limits:
Total number of records retrieved by SOQL queries

Total number of records retrieved by Database.getQueryLocator
Total heap size
Maximum CPU time on the Salesforce servers
Maximum execution time for each Apex transaction

Other Limits:
StandardSetController restrictions/limits
OFFSET limits

What are the various pagination methods/design available in salesforce?


Visualforce StandardSetController
The query and queryMore Force.com SOAP API Calls
OFFSET Clauses within SOQL Queries
Your custom logic for pagination

What is a ideal pagination design?


As such there is nothing called ideal pagination in salesforce. It depends on the actual requirement and to decide on which pagination to select.

What we are going to learn?


Further posts will explain you on all possible paginations along with actual code with screenshots. We will discuss both server side pagination and client side pagination in next posts.

No comments:

Post a Comment