Business Case:
Our executive team wanted a performance dashboard that will displayed on a big screen TV in the main conference room. They wanted to make sure that the report displays near real-time data without someone having to manually reload the report.
Environment: IBM Cognos 8.4.1 Report Studio.
Solution:
Our ETL process updates the data warehouse tables every 30 minutes. I used Javascript to make the reports reload the data every 5 minutes. So the report can be left unattended, and since the report had "Report as of: " right on top, the executives will know when the report was last refreshed.
Code:
Note: The code given below has been tested for IBM Cognos 8.4.1 Report Studio. This code may not work with older versions of Cognos as is. Script was adopted from IBM Knowledge base document
Implementation:
Our executive team wanted a performance dashboard that will displayed on a big screen TV in the main conference room. They wanted to make sure that the report displays near real-time data without someone having to manually reload the report.
Environment: IBM Cognos 8.4.1 Report Studio.
Solution:
Our ETL process updates the data warehouse tables every 30 minutes. I used Javascript to make the reports reload the data every 5 minutes. So the report can be left unattended, and since the report had "Report as of: " right on top, the executives will know when the report was last refreshed.
Code:
Note: The code given below has been tested for IBM Cognos 8.4.1 Report Studio. This code may not work with older versions of Cognos as is. Script was adopted from IBM Knowledge base document
<script type="text/javascript">
// Licensed Material - Property of IBM
// © Copyright IBM Corp. 2003, 2011
var intval;
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)
{
fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );
}
var preFix = "";
if (fW.elements["cv.id"])
{
preFix = fW.elements["cv.id"].value;
}
var nameSpace = "oCV" + preFix;
if(intval!="")
{
self.clearInterval(intval);
intval="";
}
self["RunReportInterval"] = self.setInterval( nameSpace + ".getRV().RunReport()",'600000' );
intval = self["RunReportInterval"];
</script>
Implementation:
- Create an HTML item at the end of the page
- Place the above script inside the HTML item.
- Report interval (300000 in the code above) is in milliseconds, so 300000 represents 300 seconds or 5 minutes.
- In the report header or footer, place a data item with report expression "AsOfDate()"
Hi Sriram:
ReplyDeleteWould this code work on Portlets as well or only on reports in report studio? Why can we use the schedules to have the job run every 5 minutes instead of using JS? Are you doing anything different or I am missing the keypoint?
Cheers!
-Kavitha
Instead of wring such a big script we can achieve this using simple steps given at below link
Deletehttp://cognosasksumeet.blogspot.in/search/label/Auto%20Refresh%20Cognos%20Dashboard
Thanks
@Kavitha: Scheduled reports will run in the background and any saved reports will update in the serve, but if I have a report open and I want it to automatically refresh on the screen and keep updating with results, then JS is a good way to go.
ReplyDeleteIf you know a way to make this work with schedules, please post your method here and I will be happy to add it to my post as an alternative method.
Sriram.
Hi Sriram,
ReplyDeleteIs it possible to refresh the page only once and then clear it out?
Like after loading the page the page refreshes after 10 seconds (as per the set interval)and then refresh stops.How can we do that?
I am not an expert in javascript but have a requirement like that.
Cheers!
AKS
Hi AKS,
ReplyDeleteIt is not possible to refresh the report only once. Each time the report refreshes, it will be treated as a fresh run. There is know way to keep track of whether it's the first run or refresh.
Can you elaborate on why you need to do this? There may be other ways to fulfill your requirements.
Sriram.
place a data item with report expression "AsOfDate()",,,,i am new to report studio,
ReplyDeletecan u explain in detail about, which data item with report expression "AsOfDate()"
PLEASE
600 seconds is 10 minutes - FYI
ReplyDeleteThanks. Corrected it.
DeleteWould this code work on Portlets as well or only on reports in report studio?
ReplyDeleteThe code may not work as is in portlets, since we are using cognos viewer functions.
DeleteThanks Sriram, its refreshing the report. But My data is not refreshed, as i am using monitor models to collect events and this take quiet time to display on Cognos.
ReplyDeleteAny way to do this such that my prompt pages don't reappear and just remember my selections?
ReplyDeleteYou have to move your prompts to the report page and add default selections.
DeleteSriram.
http://www-01.ibm.com/support/docview.wss?uid=swg21633000
DeleteSriram:
ReplyDeleteWorks splendid. But I have a different need. The result of My report has many rows. What I need to do is that in every refresh, the next page shows up, kind of like de "monitors flights in the airport". Do you know how to do that?
Is the number of rows in your report static or can it change drastically? We can do a looping of 20 rows at a time every seconds. I have done this with charts though.. I have a slideshow of charts that change every seconds and the report auto refreshes after 10 minutes so that the chart data can be updated.
DeleteWe can consider the number of rows (per page) a "static number". Let's say 20 rows per page.
DeleteI meant total number of row in the report, not the rows per page? There must be a way to identify when all the data has been shown and when to start over.
DeleteWell, the total number of rows can change, not drastically, but can change. In normal situations would be a number between 200 and 300 rows. I estimate that 25 rows can be shown per page.
DeleteHi Sriram:
DeleteDo you think you could share your example with charts so I could try to adapt it to my report?
Hi Sriram,
ReplyDeleteI have a report with 3 pages and I want to automatically refresh and display each page every 1 minute, without manual intervention, i.e. first page is displayed, after 1minute second page is displayed, after 1minute 3rd page is displayed; a minute later first page is refreshed and displayed, etc. How can I achieve this?
Any updates for Cognos 10.2 ? Can't seem to get it to work on this version. Just keeps trying to load page.
ReplyDeleteWe recently upgraded our environment to 10.2 and the code works just fine there. Can you email me your code to cognosonsteroids@hotmail.com
DeleteSriram,
ReplyDeleteIs there any way we can achieve the same in Cognos Workspace. I created the report in RS with the above JS. It works fine standalone. But when I pull this into cognos workspace, it is not refreshing automatically. could you please advise.
The DOM object names vary from cognos connection to cognos viewer to workspace. I have to look thru IBM documentation to see if they have a function call for auto refresh in Workspace. As of now, I don't know what it is.
DeleteSriram,
DeleteThanks, When I was using the above script in Workspace there was an error with the getformwarprequest function not available. I changed
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]); ... to
var fW = document.forms["formWarpRequest_THIS_"] ? document.forms["formWarpRequest_THIS_"] : document.forms["formWarpRequest_NS_"];
But now it is saying RunReport() not available. Do you have any idea?
Thanks
I created a Page with 3 sections, each with a different Cognos 8.4 Report Studio reporting object. All 3 have the above HTML auto-refresh code. But only the right most Page window is refreshing every 5 minutes. What is missing? Does the HTML code not work in a multi-window Page?
ReplyDeleteI have been trying to achieve exacty what you did by accident!
DeleteHow did U get just one part of a page to refresh? I have been trying to do that for weeks. :'(
The code was written to refresh reports not pages. The cognos DOM object might be different. I am not sure how to make it work for different tabs.
Deletehello
ReplyDeletei have a schedueled report who runs every 30 minutes
my compeny needs this report on dashboard , i would like to reload the report every 30 minutes from the momth we was opened but the result sould be the last run report
the problem is i need result of the last 30 minutes of complite hour
like 08:00 ,08:30,09:00
thank you anat
Instead of wring such a big script we can achieve this using simple steps given at below link
ReplyDeletehttp://cognosasksumeet.blogspot.in/search/label/Auto%20Refresh%20Cognos%20Dashboard
Thanks
Hi, I am looking for an auto refresh option in Congos Analytics report page, I know there is straight forward way to refresh the dashboards in 11, but didn't see any straight forward option for report pages, can you provide the steps how we can schedule auto refresh on report pages?
ReplyDelete