COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: cognosdelaware on 01 Aug 2017 09:28:09 AM

Title: How do I validate Text Box Prompt has a value and is selected?
Post by: cognosdelaware on 01 Aug 2017 09:28:09 AM
Hi,

  I have a Multi-Select Text Box Prompt with the name called "ACCOUNT".

  As part of the control there is a box called "Choices:" which hold any values they insert(add) and then they need to select one or all of them.

  I need to do two things(via JavaScript):

1) Make sure this "Choices:" box has data in it and not empty
2) If it has data in it, that at least one item has been selected

Thanks,

Tony


 
Title: Re: How do I validate Text Box Prompt has a value and is selected?
Post by: dougp on 01 Aug 2017 10:29:31 AM
https://www.ibm.com/support/knowledgecenter/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ug_cr_rptstd.doc/c_prmpt_api_overview.html?pos=2#prompt_api_overview (https://www.ibm.com/support/knowledgecenter/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ug_cr_rptstd.doc/c_prmpt_api_overview.html?pos=2#prompt_api_overview)
Title: Re: How do I validate Text Box Prompt has a value and is selected?
Post by: cognosdelaware on 01 Aug 2017 12:50:50 PM
I was able to figure it out, for those that need it:

var report = cognos.Report.getReport("_THIS_");
var account = report.prompt.getControlByName('ACCOUNT');

if (account.getValues().length <= 0)
    {
        alert("You must enter an Account Number");
    }