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

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Prompts on Report Page with JavaScript

Started by karthik.kadambi, 09 Aug 2015 09:19:48 PM

Previous topic - Next topic

karthik.kadambi

Hi Cognoise members,

I have a set of prompt controls set up this way on a Report Page instead of a Prompt Page:

Value Prompt 1 (single select, default value) | Value Prompt 2 (single select, default value) | Value Prompt 3 (multiselect, default value picked up by JavaScript)

JavaScript Code which dynamically selects the first value:
<script>
// Attach functions to an arbitrarily named object to mimic a namespace to ensure the name uniqueness
var zxcv = {};

// Get the required prompt.
var oCR = cognos.Report.getReport("_THIS_");
var oP = oCR.prompt.getControlByName("promptCountries");

// Get the values and isolate the first value.
var allValues = oP.getValues(true);
var firstValue = allValues[0];

// Set the prompt selection to the first value.
oValues = [firstValue];
oP.setValues(oValues);

</script>


I understand that the JavaScript code will not be submitted unless I hit the "Finish" button. I would want to filter the query on the Report Page based on the first value selected when the Report is first run.

Adding this piece to the code constantly refreshes the page every sec.
oCR.sendRequest(cognos.Report.Action.FINISH);

bvk.cognoise

Hi Karthik,

Please try below mentioned code

<script type="text/javascript">
function init()
{
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms["formWarpRequest"]);
if (fW)
fW._oLstChoicesPromptName.options[2].selected = true;
canSubmitPrompt();
}
init();
</script>


Regards
Bvk
Regards
BVK

karthik.kadambi

Hi Bvk,

Thanks. It's doing the same as the one I posted. The JavaScript picks the element but doesn't filter the Report for that specific one, but instead runs for everything.