Solved

Rule not being applied after setting a value with javascript

  • 19 April 2016
  • 4 replies
  • 111 views

Badge +3

Hi,

 

I'm setting a value in a field using JavaScript, and I have a rule that show some fields based on this value but the rule is not working.

Is there any way to enable the rule? It is like is not being refreshed. However it works if I type something in the field (I cannot do this because it will be hidden)

 

Regards,

icon

Best answer by freerider38 19 April 2016, 16:12

View original

4 replies

Badge +4

Hi,

you have to say to your control to refresh :

Ex :

var control = NWF$("#" + varControlID);

control.val(value);

NWF.FormFiller.Functions.ProcessOnChange(control);

This works fine for input text

For choice field, i use :

control.trigger('change');

instead of ProcessOnChange

Regards,

Badge +8

Hello Alicia Garcia​ – What you're experiencing is likely caused by the fact that manipulating a field through JavaScript doesn't trigger a change event in the same way that manual manipulation does.

Have you tried giving focus to and away from that field after it's been changed to force the rule to re-execute?

Badge +3

Thanks, you saved me a lot of time.

Regards,

Alicia

Badge +3

Thanks, previous answer worked for me.

Reply