If you are unable to create a new account, please email support@bspsoftware.com

 

[Solved]- Java script to auto submit once,all the values of value prompt are sel

Started by xyz, 17 Jul 2017 09:47:15 AM

Previous topic - Next topic

xyz

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

xyz

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

BigChris

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?

xyz

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

xyz

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