Pages

Monday, May 5, 2014

Difference between "modified" and "dataChanged" form data methods on datasource fields

When overriding methods on a form data object, it is important to know what they do exactly!  Two methods in particular, formdataobject.modified() and formdataobject.dataChanged(), sound very similar but are different.


The important difference is that dataChanged() runs EVERY time the data is changed, while modified() only runs after successful validation!

This may seem like a "duh" post for some, but I was surprised at the number of people who couldn't tell me the difference.

So if a user changes data on a form, it may fail validation and modified() would never run.  This is often where you would prefer to hook your code since if the field doesn't truly change, you don't want anything triggered.

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Another difference is that dataChanged() event is invoked even when control value is not changed manually. I mean for example, when you init fieldValue in the process and the control value will change due to that init, dataChanged event is invoked, when modified event is only invoked when you manually change value.

    ReplyDelete
  3. Another difference is that dataChanged() event is invoked even when control value is not changed manually. I mean for example, when you init fieldValue in the process and the control value will change due to that init, dataChanged event is invoked, when modified event is only invoked when you manually change value.

    ReplyDelete