COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: xyz on 17 Jul 2017 09:47:15 AM

Title: [Solved]- Java script to auto submit once,all the values of value prompt are sel
Post by: xyz on 17 Jul 2017 09:47:15 AM
Hi All,

We have a new requirement, once after all the values of the value prompt are selected java script has to auto submit the prompt only once.

Below is the code.

<script>
var paulScripts ={}
  , oCR = cognos.Report.getReport("_THIS_");

paulScripts.getControl = function(promptName) {
  return oCR.prompt.getControlByName(promptName);
};

paulScripts.getControl('Region').setValues(paulScripts.getControl('Region').getValues(true));

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


To above code is keep on auto submitting.

Even I tried the something like below code, but it is not working.


<script>
var paulScripts ={}
  , oCR = cognos.Report.getReport("_THIS_");
var oValues;
paulScripts.getControl = function(promptName) {
  return oCR.prompt.getControlByName(promptName);
};

paulScripts.getControl('Region').setValues(paulScripts.getControl('Region').getValues(true));

var oP = paulScripts.getControl('Region').getValues(true);

var allValues = oP.getValues(true);
var firstValue = allValues[0];

var selectedValues =oP.getValues();
var value = selectedValues [0];

if(value == undefined) {
       oValues = [firstValue];
    oP.setValues(oValues);
setTimeout("promptButtonFinish();",300);
}
</script>



I am missing a piece of code to check the values are selected then only execute the finish command once.

Can some one please share you suggestions on the same.

Thanks & Regards,
XYZ
Title: Re: Java script to auto submit once, after all the values of value prompt are select
Post by: xyz on 17 Jul 2017 01:05:53 PM
Hi All,

I forgot to mention that I amusing Cognos 10.2.1, report studio and back end DB is oracle.
Can you guys please let me know, if you have any suggestions and inputs.



Thanks & Regards,
XYZ
Title: Re: Java script to auto submit once, after all the values of value prompt are select
Post by: BigChris on 18 Jul 2017 01:44:27 AM
I don't use JavaScript so I can't give you an answer, but is the prompt a multiple select prompt? If it is then how will the code know when the user has selected all of the values that they need?
Title: Re: Java script to auto submit once, after all the values of value prompt are select
Post by: xyz on 18 Jul 2017 04:23:45 AM
Hi BigChris,

Thank you very much for the reply.  This is a multi select value prompt and this prompt is cascaded prompt to another prompt in the prompt page.  Once the user runs the report first prompt is has default selection, there is a re prompt button, when the user press it other value prompt will display which has a java script, which select all the values in that prompt, once it is selected then report has to auto submit it. Instead of the manually pressing the Finish button, where user has this requirement to not press any Finish button and it should auto submit. User will change the selection after the auto submit, if he wants. User's requirement, could not help much on it.

Any how thanks BigChris for throwing some idea on it.

Thanks & Regards,
XYZ
Title: Re: [Solved]- Java script to auto submit once,all the values of value prompt are sel
Post by: xyz on 19 Jul 2017 06:42:16 AM
Hi,

With the help of some java expert in other team. We have resolved the issue.
Below is the code for reference.


<script type="text/javascript">
var oCR = cognos.Report.getReport("_THIS_");

var prompt=oCR.prompt.getControlByName('Region')
var allValues = oCR.prompt.getControlByName('Region').getValues(true);

if(allValues.length>0){

var selectedValue = prompt.getValues()[0]

if(selectedValue == undefined){

oCR.prompt.getControlByName('Region').setValues(oCR.prompt.getControlByName('Region').getValues(true));

setTimeout("promptButtonFinish();",60);

}

}
</script>



Thanks & Regards,
XYZ