A List Prompt From an Actual List

A colleague recently used this technique on my current project, so I want to make sure that credit was given where credit is due.

From Paul’s Cognos Blog: Checkbox List Prompt


2 Responses to A List Prompt From an Actual List

  1. kishore says:

    Can you explain this script below. I have a requirement when i need to autosubmit the first dynamically selected value..

    function selectPromptByValue(divId, val) {
    var oVPCont = document.getElementById(divId);
    var oVP = oVPCont.getElementsByTagName(“select”);
    var i = oVP[0].options.length;
    while (i) {
    if (oVP[0].options[–i].value==val) {

    what does “select” refer to in the getElementsByTagName? should I name my prompt with anything or is the div id=VP_TestPrompt taking care of it?

    Can you tell me how to autosubmit using java script? I tried this also but cannot get it to work..

    function init()
    var fW = (typeof getFormWarpRequest == “function” ? getFormWarpRequest() : document.forms[“formWarpRequest”]);
    if (fW)
    fW._oLstChoicesPromptName.options[2].selected = true;

    canSubmitPrompt(); does nothing while promptAction(‘finish’) is giving me an error saying ‘the secondary request failed…”

    • Bob Reddert says:


      I think you commented on the wrong post, since this is one of my functions and the post is about Paul’s post. Nevertheless:

      A “select” element is the HTML object that a drop-down list value prompt produces. Its children are “option” elements that contain the values you may select in the prompt.

      The name of the Cognos Prompt object does not matter. The function identifies the prompt solely by the div tag that contains it.

      To use this function, you create a value prompt setting the Select UI option to “Drop down list” (the default). Then immediately before the value prompt you add an HTML item with the following text:

      Immediately after the value prompt, you add another HTML item to close the div tag:

      When you call the function, you pass in the Id you gave the div tag (ex: “VP_someNameForThePrompt”) and the value you want to find in the prompt’s options. If the option is found, the function selects that option and then auto-submits it.

      Here’s how the function works:

      • It locates the div tag you passed in the first parameter.
      • It then finds the “select” HTML object that is your prompt.
      • Starting from the end of the list of options for the select element, it iterates backward through the options.
      • If it finds an option that matches the second parameter, it selects it (as if you had clicked on it) and then auto-submits it.

      My guess is that the error you are seeing is because you have the prompt set to auto-submit., so in reality, it is performing the “finish” action two times. To fix it, either change the prompt to not auto-submit (this is what I would recommend), or remove the line “promptAction(‘finish’);” from the function.

      Best of luck!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: