COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: joms on 30 Jul 2012 06:23:02 AM

Title: Limit user selection in search and select prompt
Post by: joms on 30 Jul 2012 06:23:02 AM
Hi All,

I am in need of Java code to limit user selection (say about 50) in my search and select  prompt.please anyone respond to it ASAP.
Note:I am using Cognos 10.1 (I tried almost every Google  answers  :))

Thanks,
Title: Re: Limit user selection in search and select prompt
Post by: pricter on 30 Jul 2012 07:46:03 AM
Hi,

Have you tried the solution that it is proposed to the following site

http://www.biprofessional.net/journal/2011/6/9/checkbox-prompt-and-search-and-select-prompts-with-limiter.html (http://www.biprofessional.net/journal/2011/6/9/checkbox-prompt-and-search-and-select-prompts-with-limiter.html)
Title: Re: Limit user selection in search and select prompt
Post by: joms on 30 Jul 2012 11:13:19 PM
Yes pricter,I tried it .But with no success.Can anyonce post a code for Cognos 10 for this requirement.

Cheers,
Joms
Title: Re: Limit user selection in search and select prompt
Post by: joms on 31 Jul 2012 07:22:39 AM
Finally got it!!!

Here is the procedure:
tag HTML item with (left of the prompt)
   </div>
    <script>
    //alert('The javascript is running.');
    function CountSelected()
    { 
        var Book_prompt = document.getElementById("selectValues");
        var selectObject =  Book_prompt.getElementsByTagName("SELECT");
        var Book_promptDetails = null;
        var Search1Len = 0;
        var foundSelections = false;
        //second SELECT tag has the selected Choices as
        //OPTIONs. The first SELECT tag has the choices
        //available to choose from (search result). To check
        //whether any values are selected by the user..
        if (selectObject[1] && selectObject[1] != undefined)
        {
            Book_promptDetails = selectObject[1].getElementsByTagName('OPTION');
            Search1Len = Book_promptDetails.length;
            //alert('The number of selections is ' + Search1Len);
            if (Search1Len < 51)                   //Input the value to limit selected items here
            {
                foundSelections = true;
              }
            //alert('The foundSelections value is ' + foundSelections);
        }
            if (foundSelections == true)
        {
         promptAction('finish');
         //clsPromptButtonAction('FINISH');

        }
            else
        {
            alert('The number of selected items is too high, it should be 50 or less, you currently have ' + Search1Len + ' items selected.  Please remove some items then click on Finish again.');
        }
    }   
    //CountSelected();
    </script>

tag HTML item with (right of the prompt):
<div id='selectValues'>

remove finish button and tag HTML item with:

<button type="button" name="finishCheckDate" id="finishCheckDate" style=""
class="clsPromptButton" onmouseover="this.className = 'clsPromptButtonOver'"
onmouseout="this.className = 'clsPromptButton'"
onClick="CountSelected()">FINISH

Enjoy!!!

Cheers.
Joms