How do you force a page submit when paginating through a report?
Standard behaviour from apex is to redirect when navigating through the recordset of a report. While this is advisable in most cases, we sometimes need processes to run when the user clicks the next or previous button.
I have often seen the question, but never an answer. Although this can be achieved fairly easy, with following steps.
1) Adapt the report template. Best is to create a new report template, based on an existing template, so we don’t affect all pages.
I copy “Standard Report” and name it “Standard Report with Submit”.
2) In this new template we are interesting in the “Pagination Subtemplate”. We change “Next Page Template”, the original value will be a redirect:
<a href=”#LINK#”>next</a>
We can easily change this to a submit:
<a href=”javascript:doSubmit(‘#LINK#’);”>next</a>
And we change “Previous Page Template” analogous from :
<a href=”#LINK#”>previous</a>
to:
<a href=”javascript:doSubmit(‘#LINK#’);”>previous</a>
3) When we use this report template on our page, the next and previous button will submit, and the request will be the url it wants to redirect too. This way we can use our ‘after submit’-processes.
4) The last step we need is to foresee a branch.
We create a branch to URL, and our url will be our request:
&REQUEST.
We make the branche conditional, based on Pl/Sql:
:REQUEST LIKE ‘f?p=%’
Steps 3 & 4 need to be repeated for every page needing this functionality. Our processes can be made conditional in the same manner as our branch.
We used this for saving our data temporarily to a collection when paginating through an updatable report, and we didn’t notice any drawbacks using this method.
Thanks for this, was looking for this solution. But is there also a way to do this when changing the page via the select list of row ranges?
Peter, this is possible, although not as simple and elegant as the next and previous links.I’ll create a new post for this, thanks for the intresting question.