I'm having a similar problem to Item change event gets triggered on Save - Forms / SharePoint Online - Plumsail Community
I have three on change events in spRendered, two of which point at the same function, and the functions that they are pointed to are also run at startup.
When they are run at startup, they are passed a parameter which suppresses alerts.
When they run from the on change events, a parameter is passed which allows the alerts.
The problem is that while the non-alert functions run fine, the on change events also run (without any change having happened), and run the functions with the parameter which shows the alerts.
Code snippet from spRendered is below. Am I doing something wrong?
Regards
Nick
doBoth(0); fd.field('ProjectFrameworkType').$on('change', doBoth(99)); fd.field('CurrentStage').$on('change', getStageNumber(10)); fd.field('NPDStage').$on('change', getStageNumber(20)); function doBoth(showAlert){ swapFieldsNPD(showAlert); getStageNumber(30); } function swapFieldsNPD(alertOn) { alert(alertOn); if(fd.field('ProjectFrameworkType').value == "NPD Project"){ if(alertOn == 99){ alert("This an NPD Project"); } fd.field('CurrentStage').disabled = true; fd.field('NPDStage').disabled = false; }else{ if(alertOn == 99){ alert("This is not an NPD Project"); } fd.field('CurrentStage').disabled = false; fd.field('NPDStage').disabled = true; } }