Friday, February 26, 2010

Set Font for Date Prompts using JavaScript

Have you ever wondered how to set the font for a date prompt. Date prompts provided by Cognos do not have a Font property. Whe you design report prompt pages and set the font for all other objects and if you have date prompts for which Font is not set, it sticks out in your prompt page (if you know what I mean).

So here is a small script to help set the Font.

var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)
{ fW = ( formWarpRequest_THIS_ ?formWarpRequest_THIS_ : formWarpRequest_NS_ );
var FromDateTextBox = fW.txtDateFromDate; = 'Arial'; = '8pt';

where the date prompt is named as FromDate.

Note: This technique uses JavaScript against underlying report objects in a IBM Cognos 8 BI report. For this reason, there is no guarantee that reports created using this technique will migrate or upgrade successfully to future versions without requiring modifications. Any such modifications are the responsibility of the report designer.


aviator said...

Hi , i am using 8.4 and the above JS is not working for me.


Zephyr said...

Hi Sudhir, Couple of things you would need to check:

Ensure that you are using the Name of the prompt not the parameter name in your JS.

You have placed the JS after the object or way below the report. Basically not before the date prompt.