A customer had created a BI Workspace in SAP BusinessObjects BI4 and wanted to make it available on a large display, while having it auto-refresh within a predefined interval.
Solution
We can open the BI Workspace using an OpenDocument link (note that this works for other document types as well, refer to the OpenDocument manual for more information). If we use an iframe
to display the content, the parent document can still control the iframe
and thereby refresh the content periodically.
The OpenDocument link will still require authentication, either through SSO or by entering the username and password manually. Alternatively, you could use the REST SDK to generate a token, based on authentication details (username, password), e.g. passed through URL parameters.
If the content is refreshed before the idle session timeout occurs, the credentials will not be required again (you will just reuse the active session).
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Dashboard</title>
<script src="jquery-3.1.1.min.js"></script>
<style type="text/css">
body, html { margin: 0px; padding: 0px; height: 100%; overflow: hidden; }
#content { position:absolute; left: 0px; right: 0px; bottom: 0px; top: 0px; }
</style>
</head>
<body>
<div id='content'>
<iframe width='100%' height='100%' frameborder='0' id='opendoc' src='<Enter the OpenDocument link here>'></iframe>
</div>
</body>
<script>
window.setInterval("reloadIFrame();", 60000); // milliseconds
function reloadIFrame() {
document.getElementById('opendoc').src = document.getElementById('opendoc').src;
}
</script>
</html>
If you’re interacting with the document (e.g. setting a filter, etc), you’ll receive the alert “You will lose any unsaved modifications to this document.” when the timer expires and the iframe
‘s source is reloaded (the browser sees this as navigating away from the page, triggering the alert). This will block the reload until someone clicks the Yes button.
We can circumvent this by deleting and recreating the iframe
instead of changing the src
attribute. To do so, replace the reloadIFrame()
function from the previous code snippet with the version below. You can also remove the iframe
tag in the HTML code, as the iframe
will be created automatically, just don’t forget to call reloadIFrame()
when the document is ready (otherwise you’ll end up with an empty page until the reload interval is reached).
function reloadIFrame() {
var opendocFrame;
try {
opendocFrame = document.getElementById('opendoc');
opendocFrame.parentNode.removeChild(opendocFrame);
} catch (e){
//Ignore the exception if the element can't be found
}
opendocFrame = document.createElement('iframe');
opendocFrame.width='100%';
opendocFrame.height='100%';
opendocFrame.frameborder='0';
opendocFrame.id='opendoc';
opendocFrame.src='<Enter the OpenDocument link here>';
document.getElementById('content').appendChild(opendocFrame);
}
$(document).ready(function() {
reloadIFrame();
});