/content/folder[@name='Samples']/folder[@name='Models']/package[@name='GO Data Warehouse (query)']/model[@name='model']
Start Date:End Date:Product Line :Product Type :Products:Order Method :
<script>
var paulScripts = {}
, oCR = cognos.Report.getReport("_THIS_")
, gateway = window['oCV_THIS_'].getRV().getCV().sGateway
, report1 = decodeURIComponent("%2Fcontent%2Ffolder%5B%40name%3D%27JavaScript%20Examples%27%5D%2Ffolder%5B%40name%3D%27Drill%20Target%27%5D%2Freport%5B%40name%3D%27Target%27%5D%0A%0A");
/* function paulScripts.URLEncode - Paul Mendelson = 2013-10-21
* Based on the JSONEncode function, this will return the use/display values of
* a prompt in a format that can be based via POST or GET.
* usage: 'p_Parameter1='+paulScripts.URLEncode(paulScripts.getControl('MyPrompt'))
*/
paulScripts.URLEncode = function(promptControl){
var urlData = '<selectChoices>'
, aPromptValues = promptControl.getValues()
, nonRange = []
, range =[];
if (aPromptValues.length == 0) {return false}
for (var j=0; j< aPromptValues.length; j++) {
var promptValue = aPromptValues[j];
if (promptValue.use) {// Non Range value
nonRange.push("<selectOption useValue='"+promptValue.use + "' displayValue='"+ promptValue.display + "'/>");
}
else { // Range value
var rangeStart = promptValue.start
, rangeEnd = promptValue.end
, start, end, startDisp, endDisp;
if (rangeStart && rangeEnd) { //has both Start and End (bounded)
rangeStart.display?startDisp = " displayValue='"+ rangeStart.display+"'":"";
rangeEnd.display?endDisp = " displayValue='"+ rangeEnd.display+"'":"";
range.push("<selectBoundRange><start useValue='"+rangeStart.use +"'" + startDisp +"/><end useValue='"+rangeEnd.use +"'" + endDisp +"/></selectBoundRange>")
}
else if (rangeStart && !rangeEnd) {//unboundedEndRange
rangeStart.display?startDisp = " displayValue='"+ rangeStart.display+"'":"";
range.push("<selectUnboundedEndRange><start useValue='"+rangeStart.use +"'" + startDisp +"/></selectUnboundedEndRange>");
}
else if (!rangeStart && rangeEnd) {
rangeEnd.display?endDisp = " displayValue='"+ rangeEnd.display+"'":"";
range.push("<selectUnboundedStartRange><end useValue='"+rangeEnd.use +"'" + endDisp +"/></selectUnboundedStartRange>");
}
else {
alert ("Range not set.");
} // end if
} // end if
} // end for
if(nonRange.length>0) urlData += nonRange.join();
if(range.length>0) urlData += range.join();
urlData+='</selectChoices>';
return urlData;
}
/* function paulScripts.getPrompts
* Paul Mendelson - 2013-10-21
* Retrieves all the prompts on the page and returns the parameter values
*/
paulScripts.getPrompts = function(){
//find all of the controls and stick them in aPromptControls.
var aPromptControls = oCR.prompt.getControls( ),
prompts = [];
//loop through the controls - finding the name and values and sticking them into the names array
for(i=0;i<aPromptControls.length;i++)
{
if(aPromptControls[i].getValues().length == 0) continue;
prompts.push(aPromptControls[i].getParameterName());
prompts.push(paulScripts.URLEncode (aPromptControls[i]));
}
return prompts;
}
paulScripts.runReport = function(reportName,reportPath,gateway, prompts){
var basicInfo = [
reportName, "toolbar=no,height=200,width=400"
, 'ui.gateway' , gateway
, 'ui.tool' , 'CognosViewer'
, 'ui.action' , 'run'
, 'ui.object' , reportPath
, "run.prompt" ,"false"
, "cv.toolbar" ,"false"
, "cv.header" ,"false"
, "run.prompt", "false"
];
basicInfo=basicInfo.concat(prompts);
return cognosLaunchInWindow.apply(this,basicInfo);
}
</script>
<input type="button" onclick="paulScripts.runReport('_blank',report1,gateway, paulScripts.getPrompts())" value="Run Report 1"/>
Pass prompt values without page refresh[Sales (query)].[Products].[Product line][Sales (query)].[Products].[Product line code][Sales (query)].[Products].[Product type][Sales (query)].[Products].[Product type code][Sales (query)].[Order method].[Order method type][Sales (query)].[Order method].[Order method code][Sales (query)].[Products].[Product key][Sales (query)].[Products].[Product]