Monday, January 30, 2012

Hide Toolbar Buttons in Cognos Viewer

Business Case:
Report Author wants to hide the individual toolbar buttons found in Cognos Viewer or the entire toolbar.

Environment: IBM Cognos 8, Report Studio, Javascript, HTML Format, Internet Explorer/Mozilla Firefox.

There are many reasons why a report author might want to hide the buttons or the toolbar. For example, if a report is a drill through target report, then the users shouldn't be able to run the report again from within the cognos viewer as parameters will not be passed.

Another example is, if the drill through report can be viewed only in one format, then the author might want to hide the Report Formats button.

The toolbar inside the Cognos Viewer and it's buttons are nothing but HTML elements. So, we can use Javascript to hide them. There are two different scripts that can be used to achieve this.

Script 1 - Use IBM's built in Object Names and Methods to hide individual elements:
IBM provides this script in their knowledge base. I am using a shorter and slightly modified version of this script here:
<script language="JavaScript">
// Licensed Material - Property of IBM
// © Copyright IBM Corporation 2003, 2009

function hideKeepVersion(){
  document.getElementById("_NS_keepThisVersion").style.display = "none";

var tbCurrent = null;
var hideTheKeepVersionButton = true;
var y=getFormWarpRequest().elements[""];

// RS means it has been launched from Report Studio
// _NS_ means it has been launched from Cognos Connection
if(y.value == "RS")
  tbCurrent = oCVRS.rvMainWnd.getToolbar();
  tbCurrent = oCV_NS_.rvMainWnd.getToolbar();

if(y.value == "_NS_" && hideTheKeepVersionButton)

var tbItems = tbCurrent.m_items;

for (var item in tbItems){
  // Hide Drill Up and Drill Down Buttons
  if (tbItems[item].m_id == y.value + 'drillUp' || tbItems[item].m_id == y.value + 'drillDown')

  // Hide Open With Button
  if (tbItems[item].m_id == y.value + 'openWith')

  // Hide Run Report Button
  if (tbItems[item].m_id == y.value + 'runReport'){

  • The advantage of this script is that it provides a handle for each of the toolbar buttons individually.
  • On the flip side, since these are built in objects, it doesn't give much room for tweaking or manipulating and it's more of a use as is approach.
  • Link to IBM Knowledge base Article.
Script 2 - Use HTML DOM objects to hide the toolbar:
This is a much simpler script. The script scans the HTML page and looks for the toolbar. It then hides the toolbar completely.
<script type="text/javascript">
var tables = document.getElementsByTagName("table");
var tds = document.getElementsByTagName("td");

for (var i=0;i<tds.length;i++){
  if(tds[i].id.indexOf("CVToolbar") == 0){
    alert("Found ToolBar: " + tds[i].id + " - " + tds[i].id.indexOf("CVToolbar"));
    tds[i].style.display = 'none';

How to use the scripts:
  • Create an HTML element at the end of the page and place the script in there.
  • The script will work in both Firefox and Internet Explorer.


  1. Hi Sriram:

    Also found out that if we add &cv.header=false&cv.toolbar=false at the end of the URL removes the toolbar as well.


    1. Hi Kavitha,

      You are right. This is another method to hide the toolbar. Unfortunately, this won't work for drillthru reports as you don't have control over the html parameters. I am planning to do a separate article on URL tweaking though, where I will include this.

      Thanks for the comment.

    2. Here is the link


    3. đồng tâm
      game mu
      cho thuê phòng trọ
      cho thuê phòng trọ
      nhac san cuc manh
      tư vấn pháp luật qua điện thoại
      văn phòng luật
      số điện thoại tư vấn luật
      dịch vụ thành lập doanh nghiệp
      chém gió
      Đối với sự suy đoán của lão giả tóc trắng, Nhạc Thành không thể không bội phục, học viện đấu khí quả nhiên là có rất nhiều nhân tài.

      - Nhạc gia, Thần Hoàng tộc, Hắc Ám thần điện lại sắp khai chiến.

      Lão giả tóc trắng kia thở dài sau đó nói với Hàn Giang Đào:

      - Chúng ta quay về đi, nơi này có cao nhân, bọn họ cũng sẽ không xảy ra nguy hiểm gì.

      Bạch trưởng lão, có muốn mang Đông Phương Lạc Nhan về học viện không, như vậy sẽ an toàn hơn.

      Hàn Giang Đào nói với lão giả tóc trắng.

      - Không cần, để cho Lạc Nhan đi theo Nhạc Thành là được rồi, nó cũng cần rèn luyện một chút.

      Trương lão họ Bạch kia khẽ nói.

      - Nhạc Thành, ngươi đi theo ta ra ngoài này một chút.

  2. Hey Sriram,
    Great post. Couldnt you control this through native Cognos security as well? I believe there is an option in the cognos connection security settings in the admin portal. Keep up the great work.

    1. Hi Ro,

      Thank you for the comment. Any change done at the security settings level will be global. This solution is for cases where the toolbar has to be hidden only for a specific report.


  3. Hi Sriram,
    I have a requirement to create multiple drill-through definitions using javascript. Can u please help me.


  4. Hi Sriram ,

    I have tried the code above and it worked. But I also want to hide View in xml and View in excel option please share the code.
    I am using cognos 10.1.1

  5. Hi, I have drill through on crosstab fact, I am trying to hilight the crosstab fact cell when the user clicks on it, Also I am showing the tooltip. Do you have script for this ?

  6. Hi Sriram,

    Thanks for this. I need to remove the "Keep versions" button and this works well when the page first loads. The problem I'm having now is that we have a reprompt button on some of our reports and if we reprompt then the "Keep versions" button reappears.

    Do you know how I can hook this into a reprompt event because neither $(document).ready nor $(window).load seem to fire on a reprompt.


  7. Hi Sriram, How can the "View in Excel Option" button in Cognos Viewer be hidden ?

  8. Hi,
    Is there any way you can hide "Save Report" and "Save Report View as" from "Keep This Version"?
    If yes can you please tell me. I am using 8.4

    1. HI Sriram , How can we close the cognos viewer using javascript on clicking a image/text/button.

    2. Hello Chirag,

      Is your problem has been resolved? can you share the resolution. I'm having same problem right now. Thanks!

    3. Hi,

      While we are discussing on hiding objects..we have a requirement where in we would like to hide address bar from a drill through report.

      The entire scenario is as:

      We have dashboard embedded in a portal ( used Iframes) , we have some drill through reports, we want to hide the address bar for the drill through reports from the pop up window.

      Anyone who has implemented this or any suggestions or work around.


  9. I found simpler steps to do this here