Reputation: 1
I have a form with two datasources that are linked by using an outer join. It is written to the database by using Form Datasource Unit of Work framework.
As of now, the data gets written when moving from one datasource form control to another form datasource control. I want to only activate/write using Form Datasource Unit of Framework when a button is clicked.
Is there a way to prevent automated write function when moving from one Form Control to another?
Upvotes: 0
Views: 1792
Reputation: 18051
First have a look on HowTo: Unit of work implementation for a Form to check you align with that. The official doc is Change Group and Optional Record Modes.
The writes are issued because you are "leaving" a record, see Event Method Sequences when Focus is Removed from a Record.
This is the sequence when validateWrite
returns true:
This is the sequence when validateWrite
returns false:
So you can override validateWrite
to silently return false, when you do not want to save. Be sure to call super()
when you do want to save!
Or you can call leaveRecord
yourself to force a write:
if (record_ds.leaveRecord(true))
{}
When calling record_ds.leaveRecord(true) please observe that it may not save the record, e.g. if validation fails. In that case leaveRecord will return false.
Observe that you are working "against" the standard working, this will make your form work differently than other forms.
Upvotes: 1