Two similar solution model methods, but one doesn't work

I know that the answer is there in plain view, but I can’t see it. So, please help. I have created a solution model form with 1 button, some drop down fields and two methods: on click for the button, on data change for the fields.

but.onAction = frm.newMethod("function onClick(event) { application.output(event.getType()); }");
frmFld.onDataChange = frm.newMethod("function onDataChange(event) { application.output(event.getType()); }");

The first method, the one associated to the onAction event of the button, works ok, while the other one, associated to the onDataChange event of the drop down field, throws an error: the script is activated but ‘event’ is always null. Where am I wrong?

Hi Rioba,

The onDataChange event gets 3 arguments and the JSEvent is not the first one.
Here are the arguments for each event:

  • onAction(event)
  • onDataChange(oldValue, newValue, event)

So your code could be changed like so to make it work:

but.onAction = frm.newMethod("function onClick(event) { application.output(event.getType()); }");
frmFld.onDataChange = frm.newMethod("function onDataChange(oldValue, newValue, event) { application.output(event.getType()); }");

Hope this helps.

Elementary, my dear Watson. This is what happens when one tries to remember everything and doesn’t check the docs. Thanks, most helpful as usual.