COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: gaurav2289 on 18 Aug 2010 02:32:00 AM

Title: Set Default Selection Of a Value Prompt using Java Script
Post by: gaurav2289 on 18 Aug 2010 02:32:00 AM
Hi,

I want to set the default selection of a value prompt to a value which is result of a query. The result of query changes according to the Logged in user.

Would anybody provide me the required Java Script or Any other method to accomplish this task.

Thanks in Advance.
Title: Re: Set Default Selection Of a Value Prompt using Java Script
Post by: gaurav2289 on 18 Aug 2010 09:09:46 AM
Hi All,

I tried this -- I added another value prompt (hidden) and that prompt pulls the value which I want to select in the first value prompt. Code for this is --

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

var prompt = f._oLstChoicesMyPrompt1;

var prompt2=f._oLstChoicesMyPrompt;
prompt2.remove(1);
prompt2.remove(0);

if ( prompt2 && prompt2.options.length>2)
{


      var j=0;
      for(j=0;i<prompt2.options.length;j++)
          {
               
      if(prompt2.options[j].value==prompt.options[2].value)
                        {
                       
            prompt2.options.selectedIndex=j;
            prompt2.removeAttribute("hasLabel");
            canSubmitPrompt();
            break;
                       
                       }
          }
}
</script>


However my aim was only to set the default value but this always displays the same value in the prompt. Even if I run the report for some diffrent value, though the data displyed is filtered according the selected value but the value shown in the prompt remains same.
Can anyone suggest any solution for it?