Jump to content
We've recently updated our Privacy Statement, available here ×

Programatically Refresh Report


sgalaise
Go to solution Solved by yama818,

Recommended Posts

We have some custom javascript added to our report that performs some backend updates to our database.  The benefit is that our report is now interactive, but I am trying to determine how to refresh the current report (similar to the refresh button in the report header) once our API call returns since the action changes the dataset being returned.  Anyone have any ides?

Thanks,
Scott

EDIT:

For reference, I chose to go the route that Yama818 suggested, but this can be done using the javascript Report object.  Open a report in the browser and open up the dev console and type the following:

Report.refreshReport();[/code]

You will see the report refreshes.  I chose not to go this route because I have added an additional event listener on the mouseup event since we are populating part of the DOM after the fact (This lisetener function will now fire if a user manually refreshes the report or we do it programatically).  It would be a lot easier if we could embed custom javascript in the report itself instead of creating global javascipt functions in the ViewReport.jsp and manipulating the DOM to trigger events that way.

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

This may well be an issue with scope/context - I don't think there's any readily available means to refresh a data set from within the context of a report. Without that, I don't think what you describe is feasible. What I'd consider is having some type of custom event sequencer such as:

1) run report

2) run javascript to update DB

3) run report again if data changed

If you're using javascript to interact with the DB, you can also use it to create the suggested sequence as a whole, assuming you're displaying this in a standard web page etc. A sequence of event handlers should do the trick.

Link to comment
Share on other sites

  • Solution

Let me tell you that I may not have understood your requirement.

I have solved this before by auto-pressing the standard reload button from javascript embedded in the report.
Note that it is not picked up by the 'click' event, but by the 'mouseup'.

var mouseupEvent = new Event('mouseup');document.getElementById('dataRefreshButton').dispatchEvent(mouseupEvent);[/code]

Also, depending on the version of JRS, it may not work.
The JRS I had success with was JRS 6.4.2.
I hope this helps.

Link to comment
Share on other sites

I have solved this before by auto-pressing the standard reload button from javascript embedded in the report.
Note that it is not picked up by the 'click' event, but by the 'mouseup'.

Brilliant! I was going to use the dom to hide the row, but it never occurred to me to dispatch an event! Works beautiful!

(Not sure why I can't comment on your answer....)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...