AnsweredAssumed Answered

Issue with lookup change event firing on form load - Nintex forms version 2.7

Question asked by scottiwillis on Jan 18, 2016
Latest reply on Apr 3, 2017 by ksivanandan

Hi there Nintex community,

 

I am having an issue with the Nintex forms lookup list controls change event handler, whereby the event handler is firing as the form is loading. The handler have alerts that are displayed are fired on change of the selected item, so these are being show as the form is loading, which is not good

 

I searched the Nintex forums for the issue and found a couple of posts indicating that in newer version of Nintex Forms, the lookup control has been changed to load data asynchronous after page loaded. So based on this I moved the registration of the handler to NWF.FormFiller.Events.RegisterAfterReady. I also added;

 

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

 

 

 

    var EngagementType = NWF$('#' + ddlEngagementType);

    EngagementType.change(function (e) {

        if (e.originalEvent!=undefined){

            if (EngagementType.val()!="")

            {

                alert("Engagement type changed");

            }

 

I also read in a post that the lookup change event fires (ie when data fetched and populated, it's a change), you check if it is triggered by forms or human (using e.originalEvent check), and if value is empty (means the Please Select... on dropdown list type lookup). So I added these conditions to the events register on change.

 

However, the alert is still firing when the form is launched in edit mode. In fact, the change event is fired 3 times when the form is loaded in edit mode;

 

1) EngagementType.val is "" and e.originalEvent id defined

2) EngagementType.val is "13" and e.originalEvent id defined (alert displayed)

3) EngagementType.val is "13" and e.originalEvent id undefined

 

I really need the change event registered after the form lookup control has been loaded with data and selected value set by the form load. Alternatively is there a way to check if the event is initiated by the user or the form, as the value of e.originalEvent is actually defined for the first 2 calls as above.

 

Can anyone provide some insight to this issue?

 

Thanks,

Outcomes