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

 

Problem with JavaScript Prompt API setValidator function and Date Prompts

Started by montee, 09 May 2016 01:01:30 PM

Previous topic - Next topic

montee

Hi,

I seen to be having a problem with the JavaScript Prompt API where if I set a custom Validator function, the number of times that the function gets triggered grows (exponentially?) each time it's called.

I've stripped my JavaScript code to (what I think) is mostly barebones, and still seem to have this problem.

My HTML Item code (generic, and only requires a date prompt with the name "StartDatePrompt" as Edit box UI added to the report/prompt page):

-----------------------
<script type="text/javascript" language="javascript">

   var datevalns = {};

   datevalns.setRangeValidator = function() {
      var oCR = cognos.Report.getReport("_THIS_");
      oCR.prompt.getControlByName("StartDatePrompt").setValidator(
         function (values) {
         alert("in");
         return true;
      }
      );
      alert("set");
   }

   datevalns.setRangeValidator();
   
</script>
-----------------------

As soon as the page loads, I get the "set" alert, followed by the "in" alert. This is as expected. From the calendar date picker, I choose a date - this triggers the "in" alert twice - I expected only once, but sure.. maybe there's another trigger somewhere. I select another date using the calendar and I get the "in" alert 5 times.  And that number just grows from there...

A few things I've tried and noticed:
- I've tried doing the same with a text prompt and can't reproduce this issue
- When I just click in and out of the Date Prompt text field, I don't experience this issue - I only get the "in" alert once, as expected.
- It appears the number of times the function is called only happens when I pick a date from the calendar

Anyone have any experience with this?  Know any workarounds?

Thanks in advance for any input!