COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Esperanza on 16 Jul 2015 10:32:23 AM

Title: Prompt value with JavaScript and Scheduler
Post by: Esperanza on 16 Jul 2015 10:32:23 AM
Hello Cognos Experts!
I have a prompt page and a JavaScript HTML which select by default a date that changes every month.
This is working well.
The problem is with the scheduler.  If I schedule the report, the report failed with the following error:

The query contains one or more unresolved prompts. QE-DEF-0144 'pDate' has no substitution values.

Is there a way in JavaScript to assign the defaut value, so it could work with the scheduler?
Here is my JavaScript (my query has only one line):

<script type= text/javascript>
//<!–
function getPromptValue(pName)
{
//get report
var oCR = cognos.Report.getReport("_THIS_");
//get prompt control
var oc = oCR.prompt.getControlByName(pName);
var promptValues = oc.getValues(true);
var v=new Array();
var j=0;
//loop through all prompt value, select those meet criteria
for (var i = 0; i < promptValues.length; i++)
{
//check
if ( promptValues.use >= 20150101)
{

v [j] = { 'use': promptValues.use , 'display': promptValues.display }
j=j+1
}
}
oc.setValues(v);
}
getPromptValue("mylist");


//–>

</script>
Title: Re: Prompt value with JavaScript and Scheduler
Post by: Esperanza on 16 Jul 2015 01:34:44 PM
I found an easier way to do it.
The following Java script works fine.
My current value is selected and the report run (if done manually) with the selected value and the data is good.
Again, the problem is with the scheduler.  I got the following error :
QFS-ERR-0139 The request has multiple errors. RQP-DEF-0354 The query contains one or more unresolved prompts. QE-DEF-0387 Invalid format for numeric prompt 'pDate'.
How can it works manually but not via Cognos Scheduler ?

-----------------------------------
<script language="javascript">

function setDefaultValue()
{
var form = getFormWarpRequest();
form._oLstChoicesmylist.options[0].selected = true;

}

setDefaultValue()

</script>
---------------------------------------------
Title: Re: Prompt value with JavaScript and Scheduler
Post by: bdbits on 16 Jul 2015 02:04:21 PM
Javascript does not execute when a job runs from a schedule.