When compared to Cognos 10, Cognos 11 has a very different portal system. Called Glass, this extensions system allows a much greater flexibility in terms of adding additional buttons and menus. Pretty much every aspect of the portal can be modified, including the ellipsis menus. In addition to adding, we can also prevent users from seeing specific menu items.
1. Opening a webpage in an iFrame
2. Running a report or a dashboard
3. Opening a folder
4. Add a dashboard shape
5. Run a script
6. Adding a menu for any of the above actions
7. Hiding specific glass features or views
Let’s start with a basic extension – opening a website in an iFrame.
{ "name":"incident_Reporter_iFrame", "comment":"Opens the incident reporter in Cognos.", "schemaVersion": "1.0", "extensions": [ { "perspective": "common", "comment": "There is a special meta perspective called COMMON. Adding contributions to this perspective will cause the extension to be applied to All perspectives.", "features": [{ "id": "incidentOpener", "toolItems": [ { "comment": "This code will display a custom Website button that opens the specified URL in an iFrame.", "id": "ops.iframeOpener.incidents", "containerId": "com.ibm.bi.glass.navbarTrailingGroup", "label": "Incidents", "icon": "images/incidentReporter.png", "type": "Button", "weight": 100, "coachMark":{"title":"Incident Reporter","contents":"Use this link to open new incidents"}, "actionController": "bi/glass/api/IFrameOpener", "options": { "url": "http://SERVER/incidentReporter.aspx", "title": "Incidents" } } ] }] }]}
Let’s go through this.
Top level has name, schemaVersion, and contains the extensions array. In all places you can add a comment field.
Name should be descriptive so the next person working on this can figure this out. And then use the comment to explain what you’re doing!
Comments are just that, they’re ignored by Cognos and they’re a great place to defend your code.
The extension allows you to handle different perspectives in different ways. So you might want this to appear in one way in authoring, and another way when the user is in dashboards.
Inside extensions we start getting into how the extension appears on the page.
Perspective lets you apply this everywhere (“common”) or to a specific view (“home”, “authoring”, “dashboard”, or “modeller”).
Features defines the items in the extension.
And inside features…
id needs to be unique.
toolItems are the actual buttons and menu structure.
And inside the toolItems…
This is the place where we define what appears in the locations.
Each item needs a unique ID.
The container ID references various places in Cognos. It’s the parent of item you’re creating. The help documentation lists five placement options, but I’ll give you a hint. You can use developer toolbars to examine various elements in Cognos to see if you can put an item there:
You could also do what it says on the IBM article here, but that would be far too easy.
Label and Icon are self-explanatory.
Type can be menu, menuItem, or button. If you have a menuItem, you need to make sure the containerID is a menu. It doesn’t need to be a menu that you’ve created.
Weight determines the position of the item in the container, higher numbers making it have a higher position.
Push turns the button into a toggle.
coachMark is an object containing title and contents that creates those nice blue hint bubbles.
actionController tells Cognos what this button does. The one above opens an iFrame, but you could also use ReportOpener, DashboardOpener, FolderOpener. In my next example further down I’ll show how to run a custom controller.
Options give context to the action. In this case we want the iFrame to open incidentReporter.aspx on SERVER. If you point against an external website please note that not all websites allow themselves to be viewed in iFrames. Google for example just won’t work.
To use it you need to paste the JSON into a file called spec.json. The icon is looking for images/incidentReporter.png. Zip the spec.json and the images folder and you’re done!
Now when we upload it we see the incidents button under the Manage on the bottom left:
Now let’s do something a little more complex fun.
One of things that always bugged me about using Cognos in Chrome was the lack of clipboard access. While it’s true that you can now copy objects from report to report in C11.1, there are times when I want to modify the XML. Local classes, for example, have a very limited list of options. If I want to add something non-standard, like position:absolute, I’d have to open it in IE or copy the entire report XML.
We’re not going to get into the JS behind my Clipboard Editor, but we’ll go into the JSON of the object.
{ "name":"CognosPaul_Bag_o_Tricks", "schemaVersion": "1.0", "extensions": [ { "perspective": "authoring", "comment": "This is a collection of extensions aimed at easing the life of a developer.", "features": [{ "id": "CognosPaul.BagOTricks", "toolItems": [ { "id":"custom.appbar.trailingGroup.trickMenu", "containerId": "com.ibm.bi.glass.appbarTrailingGroup", "type": "Menu", "label": "Custom Tools", "icon": "images/bag.png", "weight": 650 }, { "id": "custom.appbar.trailingGroup.menuItem2", "comment":"Clipboard editor will allow you to copy an object in Cognos and see the XML in a memo input. You can then edit it and paste back into Cognos.", "containerId" : "custom.appbar.trailingGroup.trickMenu", "comment": "The containerId is the ID of the parent menu.", "type": "MenuItem", "actionController": "v1/ext/CognosPaul_Bag_o_Tricks/js/controllers/ClipboardEditor", "comment": "action controller is looking at the js embedded in the zip.", "label": "Edit Clipboard", "icon": "images/clipboard.png", "weight":800 } ] }] }]}
In this case I’m creating a menu in the appbarTrailingGroup. It will appear in the upper right menu bar, next to the ellipsis menu.
The menu named “CognosPaul_Bag_o_Tricks”, and that same name will be used further down in the actionController. It contains one extension, which is only valid from the authoring perspective.
The extension itself contains a menu, and a single menu item. Notice the containerId for both items. The only major difference between this and the iFrame viewer is the actionController. Notice the call is without js, and uses the name of the object: “v1/ext/EXTENSIONNAME/folderstructure/JSFILENAMEWITHOUTTHEJSEXTENSION”.
I personally find the clipboard editor incredibly useful, but because I’m using undocumented functions in Cognos I can’t guarantee that it will work for all future versions. Copying from one report to another is possible with this, but you have to initialize the report clipboard by copying something.
iFrames.zip (747 downloads)
Clipboard Editor (786 downloads)
And finally, on a personal note, I’m a sucker for free high-fives. Thanks GoTeamJosh!
I remember presenting on how to do this back in the cognos 8 world at IBM IoD….wow how things have changed….the thousands of lines of code we had to do this…now a few commands…love it.
I am the GoTeamJosh referenced in the high five section and I’m just happy to be here!
Great Job as usual.
Is it possible the report not to open in the whole window but to open in window like when you click on the Team content or Manage?
I’m a little confused – do you want the report contents to appear in the expanding sidebar when you click on the button?
Yes, this exactly hat I meant. When you click the button the report content to appear on the side bar, like when you click the manage the accounts,licenses appear on the sidebar.
Hello,
Thank you very much for your posts. I’m trying to customize the QuickStart menu that is in the Home perspective but all I can do is to hide entries like :
“excludeItems”:[“com.ibm.bi.cahome_common.1″,”com.ibm.bi.cahome_common.2″,”com.ibm.bi.cahome_common.3″,”com.ibm.bi.cahome_common.4”]
but when trying to add new one it doesn’t work, could you please give me a hand. Thank you
what are you trying to hide? You should also consider setting customization as needed.
under Manage>People>Accounts
Select the properties of role you need
go to customization
under Features you can uncheck any objects you don’t want the user to be able to see.
The priority select determines which role takes higher precedence. Admins roles always have highest priority.
Hi All,
Can we select set of rows using check box in the report viewer. After selecting we need to upload that selected data into excel. Could you please let me know if we can achieve this.
Hi cognospaul,
I read below statement on the IBM Knowledge Center website: https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.1.0/com.ibm.swg.ba.cognos.ag_manage.doc/c_ag_manage_themes.html.
“When you are using a sample theme, you cannot reset your password
after it expires”
I’m curious to know whether using a sample theme will not allow me to reset my password? Please share your take on the above statement.
Thanks.
Even now with 11.1.6 they don’t supply a sample login with the option for resetting or changing your password if its expired. I’m not the biggest JS guy but its frustrating that the build something and give so little support or additional tools for.
Most of the extensions possibilities are great but there is so little formation from IBM on using the full potential if your not a big JS person, your stuck with what others give you.
Hi cognospaul,
Can the extensions spec.json file reference Cognos’ global parameters? Our extensions file has a custom button which is a link to a URL. The URL text depends on the Cognos environment – e.g. Dev, UAT, QA, Prod. We have a global parameter for that URL, with a unique value for each Cognos environment.
If no, do you know how to make it dynamic within the extensions file?
Thanks,
Yosef
Hi Yosef,
Not that I’ve seen. I’ve looked in a few places for something like that, but I think we’ll need to raise it as an enhancement request.
Hi Paul,
Weird, i thought i asked you this before but i don’t see it here. Probably that’s why i never got an answer too:)
I’m also experimenting a lot with extensions. I was trying to “upgrade” your Clipboard Editor to make it also useable for both Data Module content, as well as Dashboard content. However, it appears Cognos is saving this data (when you click Copy) somewhere else in the DOM than in the Authoring mode. I have tried my best, but couldn’t find it. Would you be able to see where this data is stored? The idea is that this would be extremely helpful. It would allow you to copy bits across dashboards, and in data modules, you could then copy over whole sections from one data module to another. Right now not possible, and sometimes this can be really annoying.
ps Thanks for being a great mentor for so many years!
Hey Joeri. I can look into it. The clipboard editor is actually an example of extreme cheating. The object XML is stored in an obfuscated object, so in one version it might be _x12 and in another it might be _Lx1. Not exactly useful. My technique is to interrogate every object in the API looking for that. It should be possible to watch the API to see what happens when you copy an object in dashboards and modules, once we can identify where and what the object is it would be simple to extend the clipboard editor to cover it.
Thanks for checking. Yes, i know, i was already spoofing their DOM in the early days to create custom prompting mechanisms in version 8 and 10.
I’ve tried setting a simple text with a code ABCDEFGHIJ, then clicking Copy in the Cognos menu and then sniffing with Chrome developer tools for that specific ABCDEFGHIJ. Nothing can be found strangely enough. Though i’m no browser dev tools expert, i do think they store it in the browser cache somewhere.
First one finding it should pay the other a beer on first occassion we meet π
Hi Paul,
Do you know if it is possible to dynamically set a Dashboard Filter in the URL or via Javascript?
I need to open a Dashboard from a Custom Web app with a specific set of parameters.
And apparently Dashboards do not support Parameters like Reports do.
I don’t think it’s possible yet, but I know it’s on the pipeline. I do have an idea for side-stepping it in with an extension. In theory the dashboard API now allows us to attach filters, but I haven’t had a chance to test it yet. If so, it should be possible to write an extension that sniffs the parameters passed to the window and apply the filters after load.
OMG these good folks @IBM surely do not want this to be easy π
Yes, I did it using Dashboard API and a Custom Extension…
Thanks for all the great stuff. Do you know if it is possible to Hide the Search feature using an extension? Most of our users have multiple roles, so removing Search for each view for each role is too time consuming. I know IBM gives an example of excluding the Notifications button, but we need to disable the Search feature. Appreciate all your Cognos tips.