Page 1 of 1

How to check if form variables have changed

PostPosted: Mon Aug 28, 2017 2:31 pm
by Bernd.N
With databaseManager.getEditedRecords() I can check if the record of a form has changed.
But when all field-dataproviders of a form are bound to form variables instead of fields of a record, how can I check if any of those have changed?

The case is that I need to fire a specific action only when something on that form changed.

I could create one simple onDataChanged-Method that will set a switch to "changed!" when one field was changed, and hook that method to all fields.
But is there maybe a more simple method?

Re: How to check if form variables have changed

PostPosted: Tue Aug 29, 2017 10:49 am
by steve1376656734
You could try using an in-memory datasource and then you could do normal data-binding and use the databaseManager.getEditedRecords()

Re: How to check if form variables have changed

PostPosted: Tue Aug 29, 2017 11:40 am
by paronne
Hi Bernd,

Just for your information, if you are using Servoy 8.1+ forms have an event onElementDataChange() which is fired each time a dataprovider changes value in the form. It overcomes the problem of having to bind the onDataChange to each single element of the form for generic logic.
Still you have to store somewhere the state of the variable to "changed" and it won't directy tell you if the dataprovider is bound to a form variable or to something else (scope variable/ foundset dataprovider); eventually you can figure it out yourself from the JSEvent of the onElementDataChange, which gives you the elementName and the dataSourceID (event.getSource().getDataSourceID()).

Regards,
Paolo