COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: RampantRedsFan on 17 Mar 2014 12:34:15 PM

Title: Access Parameters Passed via URL in Javascript on Prompt Page
Post by: RampantRedsFan on 17 Mar 2014 12:34:15 PM
Thank you to this whole community for all of the answers that you have provided in the past. This is my first time posting, but your answers to others have been very helpful to me!

I have tried everything I know, but I cannot figure out how to access parameters passed through URL in my Javascript. Please keep in mind that I am new to Javascript and competent in Cognos.

A parameter named BU is being passed (successfully) via URL through the following at the end of the URL: &p_BU=TRUCKING.

In my script I am trying to set a variable named BU based on this value. I have tried a number of things among them are:

var BU = p_BU;
var BU = prompt ( 'BU' , 'string' );
var BU = promptValue('BU');
and more

I have had no luck. Can someone please help me set this variable?

Thank you to everyone in advance!
Title: Re: Access Parameters Passed via URL in Javascript on Prompt Page
Post by: navissar on 17 Mar 2014 05:48:38 PM
I think the easiest way to do this is to add a text box prompt to your report, assign it to your parameter, hide it and then get the value from there. When you run your report via URL it will fill up with the value you pass. To get a value off a prompt there are several methods, depending on your version. If you're using Cognos 10.2 and up you can use the prompt API for this, otherwise you can get the formWarpRequest and access the prompt through there.
Title: Re: Access Parameters Passed via URL in Javascript on Prompt Page
Post by: RampantRedsFan on 18 Mar 2014 06:05:45 AM
Thank you so much for your input.

I am using 10.1.1 and your solution worked for me. I had tried something like this before, but I was missing the .value part at the end. Like I said: I'm really new to this Javascript thing. Here was my final solution.

I added a text box named BUbox and pulled the value from that box using the following:

var BU = fw._textEditBoxBUbox.value;

It works perfectly now.

Thank you again Nimrod