COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: briancole on 29 Jul 2013 02:31:35 AM

Title: Auto suggest text prompt Javascript not working in portal viewer
Post by: briancole on 29 Jul 2013 02:31:35 AM
Hi All,

First time poster, I've been looking at this problem for the last 2-3 days and I am at a loss as to how to get this working, so would appreciated some help.

I have used the following guide to put an "auto-suggest" text prompt on one of my reports and it works brilliantly when running the report in Report Studio:

https://www-304.ibm.com/connections/blogs/basupportlink/entry/auto_complete_text_box_prompt5?lang=en_us (https://www-304.ibm.com/connections/blogs/basupportlink/entry/auto_complete_text_box_prompt5?lang=en_us)

Unfortunately, as soon as I put my report into a portal viewer, I get an error message. My code is this:

<script type="text/javascript">
var customarray=new Array();
var custom2 = new Array('something','randomly','different');
var prmt = document.formWarpRequest._oLstChoicesprmt;
for (var p=0; p<prmt.length; p++)
{
customarray[p]=prmt[p].value;
}
var obj = actb(getFormWarpRequest()._textEditBoxp_txt,customarray);
</script>


"p_txt" is the name of the text box prompt
"prmt" is the name of the value prompt which is passing the suggested list of values to p_txt

The Javascript error I receive in the Cognos Portal Viewer is:

Error: 'prmt.length' is null or not an object

All searches point to integrating the following code into mine in order to get the report to work properly, but I've tried all sorts of ways and I can't get it to work at all:

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


Can anyone suggest a way to get this code to work?

Thanks in advance,
Brian
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: CognosPaul on 29 Jul 2013 10:37:07 AM
Which version do you have? If it's 10.2+ you should focus on the new Prompt API.

Assuming that it's 10.1.1 you can try the following:


<script type="text/javascript">
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)   
{
fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );
}

var customarray=new Array();
var prmt = fW._oLstChoicesprmt;
for (var p=0; p<prmt.length; p++)
{
customarray[p]=prmt[p].value;
}
var obj = actb(fW._textEditBoxp_txt,customarray);


</script>


I recognize that code, and implemented it at one of my clients. If my suggestion doesn't work I'll log in and see exactly how I did it.
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: briancole on 30 Jul 2013 07:36:33 AM
Thank you Paul, you are an absolute legend! That worked straight away. I can't count the number of hours I've spent looking at this, now we can deploy the report I've been working on  :D

Yes, I am using 10.1.1, but we are upgrading to 10.2 in the near future, so I'll look at using the new prompt API when the upgrade happens.

Cheers again!
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: Cognosgirl1 on 07 Oct 2016 01:00:36 PM
I have cognos 10.2 and in order to get auto-suggestion for text box prompt and pass these values to the value prompt tried to use a technic  described on
http://www.performanceg2.com/searching-checkbox-cognos-10-2/     
But it is not working at all. I wonder about the last HTML item jawa script. It seems to me that it should be changed .I have tried the script you put above , but nothing happened. Does anybody know any case with the Solved solution for auto-suggestion text prompt. Thank you.
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: A_Cognos19 on 26 Nov 2018 07:51:05 AM
Hi all,

As i'm new on Cognos, Can someone tell me the steps to implement the auto suggest text box prompt ? the solution suggested by Paul ;-)

Thank you in advance
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: CognosPaul on 26 Nov 2018 10:04:43 AM
This is an ancient thread, and almost certainly not applicable to the problem you're running into. Create a new topic and make sure to include all of the details. Are you still on C10 or are you on C11? Using interactive mode? I have a few solutions that could be help, but I need to know more.
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: A_Cognos19 on 26 Nov 2018 11:05:20 AM
Hi Paul,
Thank for your answer. i'm new to Cognos..

I have a data item ( Position) with a big list values on a value prompt. i want to implement a text box prompt on which i can type a word or letters and this one allow me to select a value from a list containing the word or letters that i type.

for examaple the data item position has these values :  distributeur de frein pann de frien bogie 1 motrice impaire,  distributeur de frein pann de frien bogie 2 remorque 1 , distributeur de frein pann de frien bogie 2 remorque 2 , centrale, coupleur, bougie, reducteur, relais distributeur xa, ...etc.

and if i type in the text box prompt : "Distr", i want that the prompt suggest me only the value which contain the word "Distr" so these values :
distributeur de frein pann de frien bogie 1 motrice impaire,  distributeur de frein pann de frien bogie 2 remorque 1 , distributeur de frein pann de frien bogie 2 remorque 2 ,  relais distributeur xa.

thanks
Title: Re: Auto suggest text prompt Javascript not working in portal viewer
Post by: A_Cognos19 on 27 Nov 2018 02:52:13 AM
Hi Paul,

i'm on Cognos 11.