0

In my cognos report i am trying to have two options. Once a "Select by NDC11" radio button is selected I should be able to select the values from the list box, and when the "Select by NDC11 Textbox" radio button is selected, I should uncheck the above radio button selection and able to enter the values in the text box below.

I am not able to do the functionality to uncheck the Radio Button Group if the other is selected.

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
ashswet
  • 1
  • 1

1 Answers1

0

Assuming you are using Cognos BI version 10.2 or later you can use the Cognos JavaScript API to do what you want.

In order to manipulate prompts using the JavaScript API you have to give each prompt a unique name. For this example they will be named test1 and test2. The test1 prompt will be the prompt you want to deselect when test2 is selected.

Add a HTML item at the bottom of your prompt page and insert the following code:

<script>
var report = cognos.Report.getReport('_THIS_'); //Assign a variable to the report object
var test1 = report.prompt.getControlByName('test1'); //Assign a variable which points to the first prompt object
var test2 = report.prompt.getControlByName('test2'); //Assign a variable which points to the second prompt object

test2.setValidator(validateTest2); //Call the API's setValidator function to assign a function to fire on prompt change

function validateTest2(values) {
    if (values && values.length > 0) { //Check if test2 has a value selected
        test1.clearValues(); //Call the API's clearValues() function on test1 which deselects all values
    }
    return true; //Successfully validate prompt
}
</script>

Since we are supplying a custom validation function you may need to tweak the return value depending on if you set the prompt to required etc.

With this script, any time a value is selected in the test2 prompt, the test1 prompt will be clear.

Johnsonium
  • 2,005
  • 1
  • 13
  • 15