If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How to rename the value prompt name in congos 8.4.1

Started by jd, 07 Oct 2010 08:09:20 AM

Previous topic - Next topic

jd

How to rename the value prompt name in congos 8.4.1

Ex: I have value prompt in the prompt page that has the name Stock Type. when I run the report prompt shows Stock type but I need to change this to Select a Value

Thanks,

technomorph

I think you're talking about changing the first item that appears by default in a Value Prompt. Here's a way of doing it with JavaScript.

Using two HTML Items create a <DIV> tag around the value prompt:

<div id="VP_myPrompt">

</div>


Then add the following code to another HTML Item beneath the Value Prompt.

<script type="text/javascript">

// change first item in value prompts

   var oVPCont = document.getElementById("VP_myPrompt");
   var oVP= oVPCont.getElementsByTagName("select");
   oVP[0].options[0].text = 'Select a Value';

</script>

Lynn

A non-Java Script approach (if you can afford it performance-wise) is to make a query reference against your prompt query and simply rename the "use" data item in the reference query.

If the prompt uses only static choices then simply name the parameter as you want the label to appear such as "Select Stock Type" or whatever.

Typically prompt queries are little and run fast, so query reference is an out-of-the-box option that can help minimize the use of Java Script if so inclined in that direction. Somehow renaming the query item in the original prompt doesn't do the trick, which is annoying.

jd

Hi technomorph,

Thanks for your help. Your script worked perfectly.

One more thing, for the same prompt I have to delete the dotted below the select a value. If you have the code for that to please can you provide me.

Thanks.

technomorph


Just add the line in below:

<script type="text/javascript">

// change first item in value prompts

   var oVPCont = document.getElementById("VP_myPrompt");
   var oVP= oVPCont.getElementsByTagName("select");
   oVP[0].options[0].text = 'Select a Value';
   oVP[0].options[1] = null;

</script>


Cheers


jd

Thanks a lot technomorph.

your code solved my problem. Thanks again.

zschutz

This code is very helpful, however I am encountering one issue with it.  I used the null option to remove the first two rows from the prompt list, but the prompt now does not recognize my first two values as selectable objects.  Is there a way to remove the header text and separation line from the prompt without having this issue?

Thanks,

Arsenal

Quote from: Lynn on 07 Oct 2010 09:23:21 AM
A non-Java Script approach (if you can afford it performance-wise) is to make a query reference against your prompt query and simply rename the "use" data item in the reference query.

If the prompt uses only static choices then simply name the parameter as you want the label to appear such as "Select Stock Type" or whatever.

Typically prompt queries are little and run fast, so query reference is an out-of-the-box option that can help minimize the use of Java Script if so inclined in that direction. Somehow renaming the query item in the original prompt doesn't do the trick, which is annoying.

Hi Lynn,

Can you elaborate a little bit on your first point? Am interested in the solution, but also slightly confused (as always)  ???

Arsenal

Quote from: zschutz on 15 Feb 2011 02:10:17 PM
This code is very helpful, however I am encountering one issue with it.  I used the null option to remove the first two rows from the prompt list, but the prompt now does not recognize my first two values as selectable objects.  Is there a way to remove the header text and separation line from the prompt without having this issue?

Thanks,

I'm no JS guy and I can't guarantee that the following code won't break on upgrade but it works on 8.4.1 or at least does for value prompts in some of our reports where it's been used  ;)

Put an html item at the end of the value prompt and put the following code in it. Substitute promptname with the name you have put for the prompt box in your report (click the prompt box and put a name in the last option in the properties pane of the prompt)

<script>
document.formWarpRequest._oLstChoicespromptname.remove(0);
document.formWarpRequest._oLstChoicespromptname.removeAttribute("hasLabel");
document.formWarpRequest._oLstChoicespromptname[0].text = "Please Select a Value";
</script>

Also, you can have one single html item for all your value boxes (if you have multiple in your report) and put variations of the above 3 lines in between the script tags for each value box

Lynn

Quote from: Arsenal on 15 Feb 2011 02:21:45 PM
Hi Lynn,

Can you elaborate a little bit on your first point? Am interested in the solution, but also slightly confused (as always)  ???

Hi Arsenal,
Attached is a quick write-up that hopefully explains it a little better. If nothing else, it was an opportunity to use the word "obfuscation" today :)

To me this is one of those silly-simple things that can be done with out of the box functionality and eliminate the need for JavaScript (along with the inherent risks). Save the JS to use judiciously for stuff you really MUST do and CANNOT accomplish efficiently any other way.

There! Now I've had an opportunity to use the word "judiciously" today. Just keeps gettin' better all the time :)

Lynn

PRIT AMRIT

In fact this is a very good approach and always better to avoid JS as much as we can...

We have already implemented this technique in many of our reports and it works absolutely fine.

MFGF

That's a great trick Lynn - one I didn't know about.  Thanks for posting a very useful document!!  You should start naming these techniques as you come up with them - this one could be the "LMR Prompt Manoeuvre". 

One other minor point to add to the thread - when you move up to Cognos 10, there are now prompt properties that give you control over the name and dotted line in a value prompt, so you will be able to bin all that javascript. :)

MF.
Meep!