Saturday, July 22, 2017

OBIEE Hack: Cleanup column headings of direct SQL reports with a single mouse click

OBIEE automatically enclose column headings with double quotes if they contain spaces. This is totally unnecessary and outright annoying. Here is a bookmarklet that can do the dirty work for you: Cleanup Headings.

Drag and drop it to your browser's bookmark bar. On a direct SQL report's edit page, click it. It will do the following cleaning tasks to all column headings:

  • Remove all double quotes.
  • Replace all underscores with spaces.
  • Uppercase first letters and lowercase remaining letters of all words, except for all CAPITAL words.

Browser compatibility: Google Chrome (yes), FireFox (yes), Opera (yes), IE (no).

Here is the JavaScript code:
javascript:(function(){
window.showObieeMsg = window.showObieeMsg || function(msg){
var msgDiv = document.querySelector('td#idStatusIndicator div');
if(!msgDiv){
msgDiv = document.querySelector('td#idStatusIndicator');
msgDiv.innerHTML = '<div class=\'StatusIndicatorDiv\'></div>';
msgDiv = document.querySelector('td#idStatusIndicator div');
}
msgDiv.innerHTML = msg;
setTimeout(function(){msgDiv.innerHTML=''}, 5000);
};
document.querySelectorAll('td.SelectCellC').forEach(function(c){
var caption = c.tColNode.selectSingleNode('.//saw:text');
if(caption && caption.innerHTML){
var t = caption.innerHTML.replace(/"/g, '').split(/ |_/);
t.forEach(function(w, i){
if(!w.match(/^[A-Z]+$/))
t[i] = w[0].toUpperCase() + w.substring(1).toLowerCase();
});
caption.innerHTML = t.join(' ');
}
});
XUIPanel.getEditor('idReport').displayHTMLColumns();
showObieeMsg('All columns renamed');
})();

No comments: