Friday, March 19, 2010

Removing Parameter Name from Value Prompts

This has been covered in numerous mails, sites and posts. I am including the same here for the benefit of those who visit and use the site for all their JavaScript needs.

By default Single Select Value Prompts, display the Query Item Name as the first item in the drop down and the second item is a dotted line.

To remove the first 2 lines of value prompts follow the steps below:

Name the value prompt as PL.

Insert an HTML item below the prompt and include the below script:

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

var objProductLine = fW._oLstChoicesPL;

objProductLine .remove(1);
objProductLine .remove(0);
objProductLine .removeAttribute('hasLabel');


The first 2 lines in the value prompt are now removed.

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.


Anonymous said...

Thank you for sharing. It works with Cognos 10; new to report writer.

Ziegenbart said...

Thanks for the blog. Always nice to find other Cognos people out there.

I've been using the properties of the value prompt itself to either customize or remove the header text. Super simple and no need to use javascript with the disclaimer that there is no guarantee it will work or won't break. (I'm using Cognos 10 btw).

The default selection for the "Header Text" under "Prompt Text" for the value prompt is "Automatic".

Click on the ellipsis to the right of "Automatic" in the "Header Text" property. Change the selection to "Specified text" and leave the text field empty.

The first two lines of the Value Prompt are now removed.

You can also use this to customize what the first line says to meet business needs by entering some text (e.g. "Please make selection")

You can manipulate many of the presentation elements of a value prompt using the properties menu.

Zephyr said...

Thanks Ziegenbart. Your comments have been valuable and have been included in the latest article.

shyamthecipher said...

Thank you so much for this post.. this is so helpful to me.. I was really working hard to find out a best reference to the Java Script... ur blogpost really helped me..

Ed Pecyna said...

Thanks for your script... worked like a charm,
Cognos 8 Newbie

Victor said...

you can also achieve by the property of the value prompt. prompt text > header text > specific text

setting it to automatic text gives that unwanted line

Ricky said...

Thanks for your post. New knowledge learned for today :)

RSHAH said...

A very helpful post !!!!!
Thank you !

viswanath said...

Thanks for sharing it's working fine.