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

Solved - Prompt - Javascript

Started by LFC, 19 May 2014 05:43:34 PM

Previous topic - Next topic

LFC

Hello,
  I am trying to dynamically preselect values for checkboxlistgroup prompt at the time of prompt page load. If anybody is able to throw some light as to what exactly i am doing wrong  that would be great.

What i am trying to establish is to have certain choices in the checkbox prompt preselected dynamically( Top 6 retailers). In order to perform that i am utilizing two checkbox prompts ( one will be displayed and the other will hidden).

I am calling the below function when the user presses the Finish button using onClick event. The issue is that the code does not even execute and upon running the report i get a message from the browser that "one or more values is needed" and just proceeds to prompt me with the prompt again.


any insight would be greatly appreciated.

****************************************
<script>
function preSelectValue()
{   
   
   for(var i=0; i<checkBoxListpRetailerSource.getValues(true).length; i++)
     {
                for(var j=0; j<checkBoxListpRetailer.getValues(true).length; j++)
         {
         if ( ( checkBoxListpRetailerSource.getValues(true).display == checkBoxListpRetailer.getValues(true)[j].display  ) &&
              (checkBoxListpRetailerSource.getValues(true).checked == true ) )
                                 {
                  checkBoxListpRetailer.getValues(true)[j].checked = true;
                 break;
              }
   
                             }
               }
}

setTimeout("promptButtonFinish();",200);
</script>


<button style="" class="clsPromptButton" onmouseover="this.className = 'clsPromptButtonOver'" onmouseout="this.className = 'clsPromptButton'" onClick="preSelectValue();">&nbsp;&nbsp;Finish&nbsp;&nbsp;</button>


****************************************

LFC

strange the ["i"] counter does not show up on the original post. so using {} :o

checkBoxListpRetailerSource.getValues(true){i}.display == checkBoxListpRetailer.getValues(true)[j].display


rprameshwor

Check if the function is called or not ,
try putting up alert('foo'); at beginning of the function to see if it is called or not. If its called at beginning, move the alert downward to check if the JS function is working fine.

Having not used the .getValues(true) function , 'am not sure if it works or not [dont have env. to try it now]
You might re-write it like :

for ( i=0;i<checkboxlist.length;i++){
(if checkboxlist.checked) { .. }
}

The Error "one or more values is needed"  is thrown because the required prompts values are not given.
Probably in your case ,the JS is not executed so the hidden checkbox prompts ( which are required ) are not set and hence the error.




navissar

*sigh*
You're using prompt API syntax, which makes me assume you're on 10.2 and up. Otherwise, a whole different approach is required.
However, this code uses the prompt API as syntax only for use in old methods. For what you're trying to accomplish, you don't need loops.
Consider the following piece of code:
var mainPrompt=ocr.prompt.getControlByName(pr1);
var hiddenPrompt=ocr.prompt.getControlByName(pr2);
var theValues=hiddenPrompt.getValues(true);
mainPrompt.addValues(theValues);


The first line defines a variable to hold the main prompt object, the second line defines a variable to hold the hidden prompt object. The third line gets all values from the hidden prompt, and the fourth line marks these values in the main prompt. This is basically what you need. Remember that addValues supports adding multiple values.

So, the whole thing would be something along these lines (Note I am using a different namespace to avoid collisions):
<script>
var RNA={};
RNA.populateValues=function(pr1,pr2){
var ocr = cognos.Report.getReport("_THIS_");
var mainPrompt=ocr.prompt.getControlByName(pr1);
var hiddenPrompt=ocr.prompt.getControlByName(pr2);
var theValues=hiddenPrompt.getValues(true);
mainPrompt.addValues(theValues);
}
RNA.populateValues('main','hidden');
</script>

Note that the last row calls the function and passes the prompt names in.

If you're pre-10.2, you'll need to loop through the prompts to get what you need.

LFC

#4
Thanks for your reply Gents, I should have been little more clearer as to the reason i was looping the value and checking the display field of the prompts and i am on Cognos10.2.

The only way i could have the top 6(by Rank and can exist in random order within the prompt choices) "checked" dynamically was create a "Top 6 Indicator" in the Main prompt Query via creating a conditional column which sets '1' for Retailers with Rank 6 or below and "0" for others, again at the Prompt level i provided "1" as default selection. So all of the "Top 6" Retailers would be checked in the main prompt when the Prompt page loads by default.

So at the Main prompt my Use Value is either 1 or 0 and i used Retailer Name as the Display field for the Main prompt.

My hidden prompt which actually passes the parameter to the report has Retailer Name as the both Use and Display Values, So i cannot compare USE value from Main prompt and Hidden prompt. So i was passing the values thru the loop checking if the Display fields for both Main and Hidden prompt matched plus checking if the checkbox is checked.

So by default is the user does not make any selection and simply clicks the Finish button then only the Top6 which where checked would be passed thru to the report via the hidden prompt.

I have provided the Report Spec i made against GO SALES GEO package.
<report xmlns="http://developer.cognos.com/schemas/report/9.0/" expressionLocale="en-ca" ignoreFilterContext="false"><!--RSU-SPC-0093 The report specification was upgraded from &amp;amp;amp;quot;http://developer.cognos.com/schemas/report/6.0/&amp;amp;amp;quot; to &amp;amp;amp;quot;http://developer.cognos.com/schemas/report/9.0/&amp;amp;amp;quot; at 2014-5-19. 9:33:34--><!--RSU-SPC-0093 The report specification was upgraded from &amp;amp;amp;quot;http://developer.cognos.com/schemas/report/3.0/&amp;amp;amp;quot; to &amp;amp;amp;quot;http://developer.cognos.com/schemas/report/6.0/&amp;amp;amp;quot; at 2008-8-12. 13:38:24--><!--RS:8.2-->
<modelPath>/content/folder[@name='Packages']/package[@name='GO Sales GEO (query)']/model[@name='model']</modelPath>
<queries>
<query name="Report Query">
<source>
<model/>
</source>
<selection><dataItem aggregate="none" name="Retailer name"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem><dataItem aggregate="none" name="Retailer type"><expression>[Sales target (query)].[Retailer].[Retailer type]</expression></dataItem></selection>
<detailFilters><detailFilter><filterExpression>[Sales target (query)].[Retailer].[Retailer name] in ?pRetailer?</filterExpression></detailFilter></detailFilters></query>
<query name="Retailer"><source><model/></source><selection><dataItem aggregate="none" name="Retailer name"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem><dataItem aggregate="none" name="displayValue"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem><dataItem aggregate="none" name="Rank"><expression>rank( total( [Sales target (query)].[Sales target].[Sales target] ) )</expression></dataItem><dataItem name="Top6 Indicator"><expression>if ( [Rank] &lt;= 6 ) then ('1') else ('0')</expression></dataItem></selection><detailFilters><detailFilter><filterExpression>[Retailer name] starts with '1' or [Retailer name] starts with '4' or [Retailer name] starts with 'A' </filterExpression></detailFilter></detailFilters></query><query name="RetailerSource"><source><model/></source><selection><dataItem aggregate="none" name="Retailer name"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem><dataItem aggregate="none" name="Rank"><expression>rank( total( [Sales target (query)].[Sales target].[Sales target] ) )</expression></dataItem><dataItem name="Top6 Indicator"><expression>if ( [Rank] &lt;= 6 ) then ('1') else ('0')</expression></dataItem></selection><detailFilters><detailFilter><filterExpression>[Retailer name] starts with '1' or [Retailer name] starts with '4' or [Retailer name] starts with 'A' </filterExpression></detailFilter></detailFilters></query></queries>
<layouts>
<layout>
<reportPages>
<page name="Page1">
<pageBody>
<contents>
<list name="List1" refQuery="Report Query">



<style>
<CSS value="border-collapse:collapse"/>
<defaultStyles><defaultStyle refStyle="ls"/></defaultStyles></style>
<listColumns><listColumn><listColumnTitle><contents><textItem><dataSource><dataItemLabel refDataItem="Retailer name"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style></listColumnTitle><listColumnBody><contents><textItem><dataSource><dataItemValue refDataItem="Retailer name"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style></listColumnBody></listColumn><listColumn><listColumnTitle><contents><textItem><dataSource><dataItemLabel refDataItem="Retailer type"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style></listColumnTitle><listColumnBody><contents><textItem><dataSource><dataItemValue refDataItem="Retailer type"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style></listColumnBody></listColumn></listColumns></list>
</contents>
<style><defaultStyles><defaultStyle refStyle="pb"/></defaultStyles></style></pageBody>
<pageHeader>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue/>
</dataSource>
<style><defaultStyles><defaultStyle refStyle="tt"/></defaultStyles></style></textItem>
</contents>
<style><defaultStyles><defaultStyle refStyle="ta"/></defaultStyles></style></block>
</contents>
<style>
<CSS value="padding-bottom:10px"/>
<defaultStyles><defaultStyle refStyle="ph"/></defaultStyles></style>
</pageHeader>
<pageFooter>
<contents>
<table>
<tableRows>
<tableRow>
<tableCells>
<tableCell>
<contents>
<textItem>
<dataSource>
<reportExpression>AsOfDate()</reportExpression>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="vertical-align:top;text-align:left;width:25%"/>
</style>
</tableCell>
<tableCell>
<contents>
<textItem>
<dataSource>
<staticValue>- </staticValue>
</dataSource>
</textItem>
<textItem>
<dataSource>
<reportExpression>PageNumber()</reportExpression>
</dataSource>
</textItem>
<textItem>
<dataSource>
<staticValue> -</staticValue>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="vertical-align:top;text-align:center;width:50%"/>
</style>
</tableCell>
<tableCell>
<contents>
<textItem>
<dataSource>
<reportExpression>AsOfTime()</reportExpression>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="vertical-align:top;text-align:right;width:25%"/>
</style>
</tableCell>
</tableCells>
</tableRow>
</tableRows>
<style>
<CSS value="border-collapse:collapse;width:100%"/>
<defaultStyles><defaultStyle refStyle="tb"/></defaultStyles></style>
</table>
</contents>
<style>
<CSS value="padding-top:10px"/>
<defaultStyles><defaultStyle refStyle="pf"/></defaultStyles></style>
</pageFooter>
<style><defaultStyles><defaultStyle refStyle="pg"/></defaultStyles></style></page>
</reportPages>
<promptPages><page name="Prompt Page1">
<pageHeader>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue/>
</dataSource>
<style><defaultStyles><defaultStyle refStyle="tt"/></defaultStyles></style></textItem>
</contents>
<style><defaultStyles><defaultStyle refStyle="ta"/></defaultStyles></style></block>
</contents>
<style><defaultStyles><defaultStyle refStyle="hp"/></defaultStyles></style></pageHeader>
<pageBody>
<contents><block><contents/></block><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="border-collapse:collapse;width:100%"/></style><tableRows><tableRow><tableCells><tableCell><contents><block><contents>
<selectValue multiSelect="true" selectValueUI="checkboxGroup" name="pRetailerSource" parameter="pRetailerSource" refQuery="RetailerSource"><useItem refDataItem="Top6 Indicator"><displayItem refDataItem="Retailer name"/></useItem><defaultSelections><defaultSimpleSelection>1</defaultSimpleSelection></defaultSelections><headerText><defaultText/></headerText></selectValue><selectValue multiSelect="true" selectValueUI="checkboxGroup" name="pRetailer" refQuery="Retailer" parameter="pRetailer"><useItem refDataItem="Retailer name"><displayItem refDataItem="displayValue"/></useItem><headerText><defaultText/></headerText><propertyList><propertyItem refDataItem="Rank"/><propertyItem refDataItem="Top6 Indicator"/></propertyList></selectValue><HTMLItem>
<dataSource>
<staticValue>&lt;script&gt;
function preSelectValue()
{

for(var i=0; i&lt;checkBoxListpRetailerSource.getValues(true).length; i++)
  {
              for(var j=0; j&lt;checkBoxListpRetailer.getValues(true).length; j++)
   {
if ( ( checkBoxListpRetailerSource.getValues(true)[i].display == checkBoxListpRetailer.getValues(true)[j].display  ) &amp;&amp;
     (checkBoxListpRetailerSource.getValues(true)[i].checked == true ) )
                              {
        console.log(checkBoxListpRetailerSource.getValues(true)[i]);       
        checkBoxListpRetailer.getValues(true)[j].checked = true;
        console.log(checkBoxListpRetailer.getValues(true)[j]);
        break;
     }

                             }
               }
}

//setTimeout("promptButtonFinish();",200);
&lt;/script&gt;




</staticValue>
</dataSource>
</HTMLItem></contents><style><CSS value="margin-bottom:12px"/></style></block></contents></tableCell><tableCell><contents/></tableCell></tableCells></tableRow></tableRows></table></contents>
<style><defaultStyles><defaultStyle refStyle="py"/></defaultStyles></style></pageBody>
<pageFooter>
<contents>
<promptButton type="cancel">
<contents/>
<style><defaultStyles><defaultStyle refStyle="bp"/></defaultStyles></style></promptButton>



<HTMLItem>
<dataSource>
<staticValue>
&lt;button style="" class="clsPromptButton" onmouseover="this.className = 'clsPromptButtonOver'" onmouseout="this.className = 'clsPromptButton'" onClick="preSelectValue();"&gt;&amp;nbsp;&amp;nbsp;Finish&amp;nbsp;&amp;nbsp;&lt;/button&gt;
</staticValue>
</dataSource>
</HTMLItem>
</contents>
<style><defaultStyles><defaultStyle refStyle="fp"/></defaultStyles></style></pageFooter>
<style><defaultStyles><defaultStyle refStyle="pp"/></defaultStyles></style></page>
</promptPages></layout>
</layouts>
<XMLAttributes><XMLAttribute name="RS_CreateExtendedDataItems" output="no" value="false"/><XMLAttribute name="listSeparator" output="no" value=","/><XMLAttribute name="RS_modelModificationTime" value="2011-09-27T17:03:05.357Z" output="no"/></XMLAttributes><reportName>Cascade via Javascript ver 2</reportName></report>

navissar

Quote from: LFC on 20 May 2014 12:09:23 AM
The only way i could have the top 6(by Rank and can exist in random order within the prompt choices) "checked" dynamically was create a "Top 6 Indicator" in the Main prompt Query via creating a conditional column which sets '1' for Retailers with Rank 6 or below and "0" for others, again at the Prompt level i provided "1" as default selection. So all of the "Top 6" Retailers would be checked in the main prompt when the Prompt page loads by default.

I beg to differ.
You create one prompt for all your retailers, with retailer name as display value and retailer code as use value.
You create another query, with retailer name, retailer code and the measure you're ranking by (I assume sales), and filter it (after auto aggregation) by rank([sales])<=6.
(This is assuming relational, on dimensional you could use the topcount function).
This second query you attach to the hidden prompt (code as use, name as display), so that the hidden prompt has only 6 values to begin with. Then, you use the script sample I provided to harvest the 6 names from the hidden prompt and mark them in the main prompt. Then, you calculate how much time I just saved you, and you make a promise to invest that time in helping others on Cognoise... 8)

LFC

#6
Nimrod,
The Main(visible) prompt will not be displaying just the Top6 performers but by default it will have entire list of Retailers with the Top6 performers checked ( they need not appear right after each other but their order within the prompt will be dictated by ASC sort on Retailer Name).

As my need was little urgent i used the pre Cognos10.2 functions ( fw._oLSTChoices) to accomplish this for now. It's working but i am still going to work on getting this figured out using the Cognos10.2 prompt API and will update this post if i get it done using 10.2 API elements.

I will post the Report Spec of the working sample i have later today for others to use if they need it.






navissar

Quote from: LFC on 20 May 2014 01:30:11 AM
Nimrod,
The Main(visible) prompt will not be displaying just the Top6 performers but by default it will have entire list of Retailers with the Top6 performers checked ( they need not appear right after each other but their order within the prompt will be dictated by ASC sort on Retailer Name).

...Which is precisely what my solution does.
Step by step, and please read through:
1. Create two queries. Query 1 has retailer name and retailer code, and no filtering. Let's call it "Retailers Prompt". Query 2 has retailer name and retailer code and sales amount (Or any other measure), and is filtered after auto aggregation for rank([sales])<=6. Let's call this one "Top 6 retailers".
2. Create two checkbox prompts. Name the first one "Main" and the second one "hidden".
3. Assign "Retailers prompt" query to prompt "Main". Use code for use value, name for display value. I hope you agree with me that this prompt will show all retailers, as the query it uses is the unfiltered one.
4. Assign "Top 6 retailers" query to prompt "hidden". Again, use code for use value, name for display value. This prompt will only show the top 6 retailers.
5. Hide the "hidden" prompt.
6. Use the script sample I provided in my first comment. This will take all the values from the "hidden" prompt (top 6 retailers) and mark them (check them) in the "main" prompt (Which still shows all retailers).
Less code, less work, and a 3 minute setup in total.
I know this works, because I actually tested it prior to publishing, as is normally my habit.

LFC

#8
okay Nimrod, I solemnly pledge to spend more time than what i normally do in this forum and help others on Cognoise. ;D

The 10.2 code you provided is much simpler and straightforward than the pre10.2 code i had written. I was taking the long route( dont know why but tried mind i think) for example you mentioned to have the hidden prompt which feeds the visible prompt but in my setup the Visible prompt was feeding the Hidden prompt which feeds the report( not good approach) but live and learn right  ;)

i have listed them below for comparison incase anybody's wants to implement this for Cognos pre10.2.

Nimrod's code( cognos 10.2 version using PromptAPI):

<script>
var RNA={};
RNA.populateValues=function(pr1,pr2){
var ocr = cognos.Report.getReport("_THIS_");
var mainPrompt=ocr.prompt.getControlByName(pr1);
var hiddenPrompt=ocr.prompt.getControlByName(pr2);
var theValues=hiddenPrompt.getValues(true);
mainPrompt.addValues(theValues);
}
RNA.populateValues('pVisible','pHidden');
</script>



Pre10.2 code( not sure if what i have written is the most efficient but it did the trick as i was time constrained ). You can make it more efficient if you use Nimrod's approach as above and make the hidden prompt feed the preselected values to Visible prompt on prompt page load.

<script>
function preSelectValue()
{
var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);

for (i=0; i < fW._oLstChoicesvisible.length; i++)
  {
    for (j=0; j < fW._oLstChoiceshidden.length; j++)
    {
    if( (fW._oLstChoicesvisible[i].text == fW._oLstChoiceshidden[j].text) &&
(fW._oLstChoicesvisible[i].checked == true))
    {
       
            fW._oLstChoiceshidden[i].checked =  true;
            break;
    }
    }
  }


{promptButtonFinish();}
}
</script>
<button style="" class="clsPromptButton" onmouseover="this.className = 'clsPromptButtonOver'" onmouseout="this.className = 'clsPromptButton'" onClick="preSelectValue();">&nbsp;&nbsp;Finish&nbsp;&nbsp;</button>





LFC

#9
Report Spec for 10.2
<report xmlns="http://developer.cognos.com/schemas/report/9.0/" useStyleVersion="10" expressionLocale="en-us">
<modelPath>/content/folder[@name='Dimensional Samples']/package[@name='Great Outdoors Company']/model[@name='model']</modelPath>
<drillBehavior modelBasedDrillThru="true"/>
<layouts>
<layout>
<reportPages>
<page name="Page1">
<style>
<defaultStyles>
<defaultStyle refStyle="pg"/>
</defaultStyles>
</style>
<pageBody>
<style>
<defaultStyles>
<defaultStyle refStyle="pb"/>
</defaultStyles>
</style>
<contents><list horizontalPagination="true" name="List1" refQuery="Report Query">



<noDataHandler>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue>No Data Available</staticValue>
</dataSource>
<style>
<CSS value="padding:10px 18px;"/>
</style>
</textItem>
</contents>
</block>
</contents>
</noDataHandler>
<style>
<CSS value="border-collapse:collapse"/>
<defaultStyles>
<defaultStyle refStyle="ls"/>
</defaultStyles>
</style>
<listColumns><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Retailer name"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents><textItem><dataSource><dataItemValue refDataItem="Retailer name"/></dataSource></textItem></contents></listColumnBody></listColumn><listColumn><listColumnTitle><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style><contents><textItem><dataSource><dataItemLabel refDataItem="Retailer type"/></dataSource></textItem></contents></listColumnTitle><listColumnBody><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style><contents><textItem><dataSource><dataItemValue refDataItem="Retailer type"/></dataSource></textItem></contents></listColumnBody></listColumn></listColumns></list></contents>
</pageBody>
</page>
</reportPages>
<promptPages><page name="Prompt Page1">
<pageHeader>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue/>
</dataSource>
<style>
<defaultStyles>
<defaultStyle refStyle="tt"/>
</defaultStyles>
</style>
</textItem>
</contents>
<style>
<defaultStyles>
<defaultStyle refStyle="ta"/>
</defaultStyles>
</style>
</block>
</contents>
<style>
<defaultStyles>
<defaultStyle refStyle="hp"/>
</defaultStyles>
</style>
</pageHeader>
<pageBody>
<contents><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="border-collapse:collapse;width:100%"/></style><tableRows><tableRow><tableCells><tableCell><contents><selectValue multiSelect="true" selectValueUI="checkboxGroup" refQuery="Hidden pQuery" name="pHidden" parameter="pHidden" hideAdornments="true" required="false"><useItem refDataItem="Retailer name"><displayItem refDataItem="Retailer name"/></useItem><propertyList><propertyItem refDataItem="Rank"/><propertyItem refDataItem="Revenue1"/></propertyList><style><CSS value="visibility:hidden"/></style></selectValue></contents></tableCell></tableCells></tableRow><tableRow><tableCells><tableCell><contents><selectValue multiSelect="true" range="false" required="true" selectValueUI="checkboxGroup" refQuery="Visible pQuery" name="pVisible" parameter="pVisible" hideAdornments="true"><useItem refDataItem="Retailer name"><displayItem refDataItem="Retailer name"/></useItem></selectValue><HTMLItem>
<dataSource>
<staticValue>&lt;script&gt;
var RNA={};
RNA.populateValues=function(pr1,pr2){
var ocr = cognos.Report.getReport("_THIS_");
var mainPrompt=ocr.prompt.getControlByName(pr1);
var hiddenPrompt=ocr.prompt.getControlByName(pr2);
var theValues=hiddenPrompt.getValues(true);
mainPrompt.addValues(theValues);
}
RNA.populateValues('pVisible','pHidden');
&lt;/script&gt;</staticValue>
</dataSource>
</HTMLItem></contents></tableCell></tableCells></tableRow></tableRows></table></contents>
<style>
<defaultStyles>
<defaultStyle refStyle="py"/>
</defaultStyles>
</style>
</pageBody>
<pageFooter>
<contents>
<promptButton type="cancel">
<contents/>
<style>
<defaultStyles>
<defaultStyle refStyle="bp"/>
</defaultStyles>
</style>
</promptButton>
<promptButton type="back">
<contents/>
<style>
<defaultStyles>
<defaultStyle refStyle="bp"/>
</defaultStyles>
</style>
</promptButton>
<promptButton type="next">
<contents/>
<style>
<defaultStyles>
<defaultStyle refStyle="bp"/>
</defaultStyles>
</style>
</promptButton>
<promptButton type="finish">
<contents/>
<style>
<defaultStyles>
<defaultStyle refStyle="bp"/>
</defaultStyles>
</style>
</promptButton>
</contents>
<style>
<defaultStyles>
<defaultStyle refStyle="fp"/>
</defaultStyles>
</style>
</pageFooter>
<style>
<defaultStyles>
<defaultStyle refStyle="pp"/>
</defaultStyles>
</style>
</page></promptPages></layout>
</layouts>
<XMLAttributes><XMLAttribute name="RS_CreateExtendedDataItems" value="true" output="no"/><XMLAttribute name="listSeparator" value="," output="no"/><XMLAttribute name="RS_modelModificationTime" value="2005-11-04T15:07:21.127Z" output="no"/></XMLAttributes><queries><query name="Visible pQuery">
<source>
<model/>
</source>
<selection><dataItem name="Retailer name" aggregate="none" rollupAggregate="none"><expression>[great_outdoors_company].[Retailers].[Retailers].[Retailer]</expression><XMLAttributes><XMLAttribute name="RS_dataType" value="3" output="no"/><XMLAttribute name="RS_dataUsage" value="attribute" output="no"/></XMLAttributes></dataItem><dataItem name="Retailer code" aggregate="none" rollupAggregate="none"><expression>[great_outdoors_company].[Retailers].[Retailers].[Retailer]</expression><XMLAttributes><XMLAttribute name="RS_dataType" value="1" output="no"/><XMLAttribute name="RS_dataUsage" value="identifier" output="no"/></XMLAttributes></dataItem></selection>
</query><query name="Hidden pQuery">
<source>
<model/>
</source>
<selection><dataItem name="Retailer name" aggregate="none" rollupAggregate="none"><expression>[great_outdoors_company].[Retailers].[Retailers].[Retailer]</expression><XMLAttributes><XMLAttribute name="RS_dataType" value="3" output="no"/><XMLAttribute name="RS_dataUsage" value="attribute" output="no"/></XMLAttributes></dataItem><dataItem name="Rank"><expression>topCount( [great_outdoors_company].[Retailers].[Retailers].[Retailer] , 6 ,  [great_outdoors_company].[Measures].[Revenue] )</expression></dataItem><dataItemMeasure name="Revenue1"><dmMember><MUN>[great_outdoors_company].[Measures].[Revenue]</MUN><itemCaption>Revenue</itemCaption></dmMember><dmDimension><DUN>[great_outdoors_company].[Measures]</DUN><itemCaption>Measures</itemCaption></dmDimension><XMLAttributes><XMLAttribute name="RS_dataType" value="9" output="no"/></XMLAttributes></dataItemMeasure></selection>
</query><query name="Report Query">
<source>
<model/>
</source>
<selection><dataItem name="Retailer name" aggregate="none" rollupAggregate="none"><expression>[great_outdoors_company].[Retailers].[Retailers].[Retailer]</expression><XMLAttributes><XMLAttribute name="RS_dataType" value="3" output="no"/><XMLAttribute name="RS_dataUsage" value="attribute" output="no"/></XMLAttributes></dataItem><dataItem name="Retailer type" aggregate="none" rollupAggregate="none"><expression>[great_outdoors_company].[Retailers].[Retailers].[Retailer Type]</expression><XMLAttributes><XMLAttribute name="RS_dataType" value="3" output="no"/><XMLAttribute name="RS_dataUsage" value="attribute" output="no"/></XMLAttributes></dataItem><dataItemMeasure name="Revenue"><dmMember><MUN>[great_outdoors_company].[Measures].[Revenue]</MUN><itemCaption>Revenue</itemCaption></dmMember><dmDimension><DUN>[great_outdoors_company].[Measures]</DUN><itemCaption>Measures</itemCaption></dmDimension><XMLAttributes><XMLAttribute name="RS_dataType" value="9" output="no"/></XMLAttributes></dataItemMeasure></selection>
<detailFilters><detailFilter><filterExpression>[great_outdoors_company].[Retailers].[Retailers].[Retailer] in ( ?pVisible? )</filterExpression></detailFilter></detailFilters></query></queries><reportName>Preselect Top 6 Javascript - dimensional</reportName></report>



Report Spec for < 10.2 cognos versions.
<report xmlns="http://developer.cognos.com/schemas/report/9.0/" expressionLocale="en-ca" ignoreFilterContext="false"><!--RSU-SPC-0093 The report specification was upgraded from &amp;amp;amp;amp;quot;http://developer.cognos.com/schemas/report/6.0/&amp;amp;amp;amp;quot; to &amp;amp;amp;amp;quot;http://developer.cognos.com/schemas/report/9.0/&amp;amp;amp;amp;quot; at 2014-5-19. 9:33:34--><!--RSU-SPC-0093 The report specification was upgraded from &amp;amp;amp;amp;quot;http://developer.cognos.com/schemas/report/3.0/&amp;amp;amp;amp;quot; to &amp;amp;amp;amp;quot;http://developer.cognos.com/schemas/report/6.0/&amp;amp;amp;amp;quot; at 2008-8-12. 13:38:24--><!--RS:8.2-->
<modelPath>/content/folder[@name='Packages']/package[@name='GO Sales GEO (query)']/model[@name='model']</modelPath>
<queries>
<query name="Report Query">
<source>
<model/>
</source>
<selection><dataItem aggregate="none" name="Retailer name"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem><dataItem aggregate="none" name="Retailer type"><expression>[Sales target (query)].[Retailer].[Retailer type]</expression></dataItem></selection>
<detailFilters><detailFilter><filterExpression>[Sales target (query)].[Retailer].[Retailer name] in ?phidden?</filterExpression></detailFilter></detailFilters></query>
<query name="Hidden pQuery"><source><model/></source><selection><dataItem aggregate="none" name="Retailer name"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem><dataItem aggregate="none" name="displayValue" sort="ascending"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem></selection></query><query name="visible pQuery"><source><model/></source><selection><dataItem aggregate="none" name="Active indicator"><expression>if ([Retailer name] starts with  'A') then (1) else (0)</expression></dataItem><dataItem aggregate="none" name="Retailer name" sort="ascending"><expression>[Sales target (query)].[Retailer].[Retailer name]</expression></dataItem></selection><detailFilters><detailFilter><filterExpression>[Retailer name] starts with '1' or [Retailer name] starts with '4' or [Retailer name] starts with 'A' </filterExpression></detailFilter></detailFilters></query></queries>
<layouts>
<layout>
<reportPages>
<page name="Page1">
<pageBody>
<contents>
<list name="List1" refQuery="Report Query">



<style>
<CSS value="border-collapse:collapse"/>
<defaultStyles><defaultStyle refStyle="ls"/></defaultStyles></style>
<listColumns><listColumn><listColumnTitle><contents><textItem><dataSource><dataItemLabel refDataItem="Retailer name"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style></listColumnTitle><listColumnBody><contents><textItem><dataSource><dataItemValue refDataItem="Retailer name"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style></listColumnBody></listColumn><listColumn><listColumnTitle><contents><textItem><dataSource><dataItemLabel refDataItem="Retailer type"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lt"/></defaultStyles></style></listColumnTitle><listColumnBody><contents><textItem><dataSource><dataItemValue refDataItem="Retailer type"/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="lc"/></defaultStyles></style></listColumnBody></listColumn></listColumns></list>
</contents>
<style><defaultStyles><defaultStyle refStyle="pb"/></defaultStyles></style></pageBody>
<pageHeader>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue/>
</dataSource>
<style><defaultStyles><defaultStyle refStyle="tt"/></defaultStyles></style></textItem>
</contents>
<style><defaultStyles><defaultStyle refStyle="ta"/></defaultStyles></style></block>
</contents>
<style>
<CSS value="padding-bottom:10px"/>
<defaultStyles><defaultStyle refStyle="ph"/></defaultStyles></style>
</pageHeader>
<pageFooter>
<contents>
<table>
<tableRows>
<tableRow>
<tableCells>
<tableCell>
<contents>
<textItem>
<dataSource>
<reportExpression>AsOfDate()</reportExpression>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="vertical-align:top;text-align:left;width:25%"/>
</style>
</tableCell>
<tableCell>
<contents>
<textItem>
<dataSource>
<staticValue>- </staticValue>
</dataSource>
</textItem>
<textItem>
<dataSource>
<reportExpression>PageNumber()</reportExpression>
</dataSource>
</textItem>
<textItem>
<dataSource>
<staticValue> -</staticValue>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="vertical-align:top;text-align:center;width:50%"/>
</style>
</tableCell>
<tableCell>
<contents>
<textItem>
<dataSource>
<reportExpression>AsOfTime()</reportExpression>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="vertical-align:top;text-align:right;width:25%"/>
</style>
</tableCell>
</tableCells>
</tableRow>
</tableRows>
<style>
<CSS value="border-collapse:collapse;width:100%"/>
<defaultStyles><defaultStyle refStyle="tb"/></defaultStyles></style>
</table>
</contents>
<style>
<CSS value="padding-top:10px"/>
<defaultStyles><defaultStyle refStyle="pf"/></defaultStyles></style>
</pageFooter>
<style><defaultStyles><defaultStyle refStyle="pg"/></defaultStyles></style></page>
</reportPages>
<promptPages><page name="Prompt Page1">
<pageHeader>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue/>
</dataSource>
<style><defaultStyles><defaultStyle refStyle="tt"/></defaultStyles></style></textItem>
</contents>
<style><defaultStyles><defaultStyle refStyle="ta"/></defaultStyles></style></block>
</contents>
<style><defaultStyles><defaultStyle refStyle="hp"/></defaultStyles></style></pageHeader>
<pageBody>
<contents><block><contents><textItem><dataSource><staticValue>Retailer name</staticValue></dataSource></textItem></contents></block><block><contents><selectValue multiSelect="true" name="visible" selectValueUI="checkboxGroup" parameter="pvisible" refQuery="visible pQuery"><useItem refDataItem="Active indicator"><displayItem refDataItem="Retailer name"/></useItem><defaultSelections><defaultSimpleSelection>0</defaultSimpleSelection></defaultSelections></selectValue>
<selectValue autoSubmit="false" multiSelect="true" name="hidden" range="false" selectValueUI="checkboxGroup" parameter="phidden" refQuery="Hidden pQuery"><XMLAttributes><XMLAttribute name="dataType" output="XML" value="xsdString"/></XMLAttributes><useItem refDataItem="Retailer name"><displayItem refDataItem="displayValue"/></useItem><sortList><sortItem refDataItem="displayValue" sortOrder="ascending"/></sortList><style><CSS value="visibility:hidden"/></style></selectValue></contents><style><CSS value="margin-bottom:12px"/></style></block><table><style><defaultStyles><defaultStyle refStyle="tb"/></defaultStyles><CSS value="border-collapse:collapse;width:100%"/></style><tableRows><tableRow><tableCells><tableCell><contents/></tableCell><tableCell><contents/></tableCell></tableCells></tableRow></tableRows></table></contents>
<style><defaultStyles><defaultStyle refStyle="py"/></defaultStyles></style></pageBody>
<pageFooter>
<contents>
<promptButton type="cancel">
<contents/>
<style><defaultStyles><defaultStyle refStyle="bp"/></defaultStyles></style></promptButton>



<HTMLItem>
<dataSource>
<staticValue>&lt;script&gt;
function preSelectValue()
{
var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);

for (i=0; i &lt; fW._oLstChoicesvisible.length; i++)
  {
    for (j=0; j &lt; fW._oLstChoiceshidden.length; j++)
    {
    if( (fW._oLstChoicesvisible[i].text == fW._oLstChoiceshidden[j].text) &amp;&amp;
(fW._oLstChoicesvisible[i].checked == true))
    {
           // console.log( fW._oLstChoicesRN[i].value );
            fW._oLstChoiceshidden[i].checked =  true;
            break;
    }
    }
  }


{promptButtonFinish();}
}
&lt;/script&gt;
&lt;button style="" class="clsPromptButton" onmouseover="this.className = 'clsPromptButtonOver'" onmouseout="this.className = 'clsPromptButton'" onClick="preSelectValue();"&gt;&amp;nbsp;&amp;nbsp;Finish&amp;nbsp;&amp;nbsp;&lt;/button&gt;</staticValue>
</dataSource>
</HTMLItem>
</contents>
<style><defaultStyles><defaultStyle refStyle="fp"/></defaultStyles></style></pageFooter>
<style><defaultStyles><defaultStyle refStyle="pp"/></defaultStyles></style></page>
</promptPages></layout>
</layouts>
<XMLAttributes><XMLAttribute name="RS_CreateExtendedDataItems" output="no" value="false"/><XMLAttribute name="listSeparator" output="no" value=","/><XMLAttribute name="RS_modelModificationTime" value="2011-09-27T17:03:05.357Z" output="no"/></XMLAttributes><reportName>preselecting prompts</reportName></report>

navissar

I applaud your posting up the solutions. That's being a very good citizen; thanks.