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

 

JavaScript: Iterate through all of the prompts on a prompt page

Started by dougp, 05 Nov 2018 04:22:43 PM

Previous topic - Next topic

dougp

I want to iterate through all of the prompts on a prompt page, but I don't know how.

The documentation for the Prompt API in Cognos 10.2.2 shows a getControls() method.
https://www.ibm.com/support/knowledgecenter/en/SSEP7J_10.2.2/com.ibm.swg.ba.cognos.ug_cr_rptstd.10.2.2.doc/r_prmpt_api_cognos_prompt_getControls.html#cognos.prompt.getControls
So, in the compatible viewer, this is easy.

Looking at the documentation for the "new way" to do JavaScript in Cognos, I don't see a way to do this in the interactive viewer.  Am I just missing it, or is this feature gone?

Boksberger


CognosPaul

The JS is similar to the non-interactive version:

oControlHost.page.getAllPromptControls()

It returns an array of prompts, on each one you can do the following protos:
autoSubmit
element
name
parameter

setValues
addValues
getValues
clearValues
setValidator

get/set/toggleDisplay
get/setVisible
toggleVisibility


dougp

Good find!
I don't see it in the documentation.  Does newer documentation describe the getAllPromptControls() method?  Or is this an Easter egg?

CognosPaul

I think this might be an easter egg. I'm not finding it in the documentation either. (documentation can be found here: https://www.ibm.com/communities/analytics/cognos-analytics-blog/javascript-support-in-interactive-viewer/).

The autosubmit method is also new. I'm hoping this is the start of more of the original methods being exposed. The old API had dozens of really great functions that haven't been replicated yet.

Boksberger

IBM released new JS documentation for 11.0.10 and put it online: https://public.dhe.ibm.com/software/data/sw-library/cognos/mobile/scriptable_reports/index.html

If you want the zip, it is hosted here: https://www-01.ibm.com/support/docview.wss?uid=swg21990557

getAllPromptControls() is listed as a method for the Page interface.

CognosPaul

I was looking for that, thanks for finding the updated version!

dougp