COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: A_Cognos19 on 27 Nov 2018 04:19:49 AM

Title: Auto suggest text prompt Javascript implementation
Post by: A_Cognos19 on 27 Nov 2018 04:19:49 AM
Hi all,

i'm new on Cognos , and i'm using cognos 11, Using interactive mode.

I have a data item ( for example Pos) with a big values list . i want to implement a text box prompt on which while typing a word or letters, the text box prompt suggest me only values of the (Pos ) item that contain  the word or letters that i typed.

For example the data item (Pos) has these values : 
1-distributeur de frein pann de frien bogie 1 motrice impaire, 
2-distributeur de frein pann de frien bogie 2 remorque 1 ,
3-distributeur de frein pann de frien bogie 2 remorque 2 ,
4-centrale, coupleur, bougie,
5-reducteur,
6-relais distributeur xa, ...etc.

->if i type in the text box prompt : "Distr", i want that the prompt suggest me ONLY values  contain the word "Distr" so these values :
1-distributeur de frein pann de frien bogie 1 motrice impaire, 
2-distributeur de frein pann de frien bogie 2 remorque 1 ,
3-distributeur de frein pann de frien bogie 2 remorque 2 , 
6-relais distributeur xa.

Thank you for your help.
Title: Re: Auto suggest text prompt Javascript implementation
Post by: CognosPaul on 27 Nov 2018 08:52:11 AM
I have a solution that does exactly what you're asking for.
The attached zip contains the libraries, css, and a report XML showing how to use it.

You'll need to change the SearchPrompt.js to point to the correct location of your sol.js and sol.css. You can use an absolute path or a relative, like this. The report will also need to be modified to point to the correct SearchPrompt.js location.
Title: Re: Auto suggest text prompt Javascript implementation
Post by: A_Cognos19 on 27 Nov 2018 10:16:30 AM
Hi Paul,
thank you for your help  :).


Can you tell me steps to implement this solution. i'm a new user of cognos ( only 1  week).


thank you in advance for all
Title: Re: Auto suggest text prompt Javascript implementation
Post by: CognosPaul on 27 Nov 2018 11:33:09 AM
You will need to put the js and css files in the zip onto a webserver somewhere. It could be in the cognos webcontents, but somewhere you can easily access.

You need to be able to call them with http://servername/folder/SearchPrompt.js
Remember to modify the links to the css and sol.js inside searchprompt.js

Once you get that working open the report I included in the zip. You can right click "Report" on the left pane and "open report from clipboard". In the custom control, replace url so it points to your js file and hopefully it should work great.
Title: Re: Auto suggest text prompt Javascript implementation
Post by: pankkish on 13 Sep 2019 07:51:31 AM
Hi Paul,

Actually the requirement is to autocomplete Cognos value/text prompt with auto submit with custom control. I had used your script which is implemented using inline JavaScript which is working fine but unable to convert  this inline code into custom control unable for more scalability.

Could you please advice me .
Your help will be highly appreciable.
Title: Re: Auto suggest text prompt Javascript implementation
Post by: radid8460 on 01 May 2020 12:51:46 PM
Hi Paul,
thanks a lot, I am able to use your script in interactive mode but if I want to use it without interactive mode ..!!! is it possible ...!!! if so, could you please help me out with this. gonna be so helpful . thanks
Title: Re: Auto suggest text prompt Javascript implementation
Post by: CognosPaul on 17 Jul 2020 06:47:49 AM
Hi Radid, I wish there was a way. Unfortunately controls like this only work in interactive mode.