Nintex Forms and Javascript - Calculated field

  • 29 April 2016
  • 5 replies
  • 175 views

Badge +7

Hi,

I have a problem that is driving me crazy.

The scenario is, that I have a calculated field, that I want to do something with in Javascript when the form loads.

So I have some Javascript like this:

NWF$(document).ready(function(){

     var element = NWF$("#" + varCalculatedField);

     element.change(function() {

       console.log("element changed - value is " + element.val());

    });

});

For a more "normal" control than the calculated field, this would result in the message being written to the console.

However, for the calculated field, the ".change" event never fires, so I do not get my message.

I tried to catch it another way (very bad, but just to see it work). I basically just wait half a second from the ".ready" event on the form itself, and then run my business logic (writing to console...). This works, but of course is not a very good way to do it.

NWF$(document).ready(function(){

     var element = NWF$("#" + varCalculatedField);

     setTimeout(function() {

         console.log("element value is " + element.val());

     },500);

});

Question: What event should i listen to and respond to to make this really work?

Regards

Leif


5 replies

Badge +11

Hi Leif,

you can find a list of additional events here: JavaScript events in Nintex Forms

Maybe the "Filler After Ready" event could work for you.

Regards

Philipp

Badge +7

Hi Philipp - that did the trick, thanks for the info :-)

Regards

Leif

Badge +6

I just registered the change event of my calculated field into this form event:

NWF.FormFiller.Events.RegisterAfterReady(function () { 
NWF$("#" + MYCALCULATEDFIELD).change(function(){
alert("TEST");
});
});

Unfortunately the event doesn't fire...

Thanks for help...

Roman

Badge +8

It is the same for me. Below code does not seem to work.

Are we missing anything?

NWF.FormFiller.Events.RegisterAfterReady(function () {

NWF$("#"+ calField).change(function() {
alert(NWF$("#"+ calField).val());
});

});

Badge +8

I used the below code as workaround and works for my requirement :

NWF$(document).ready(function() {
NWF$(document).click(function() {
if(NWF$("#"+ calField).val() != NWF$("#"+ txtField).val())
NWF$("#"+ txtField).val(NWF$("#"+ calField).val());
});
});

Reply