Update value of a table field from formDatasource.modified

Hi,

Very simple situation:

I have one form, one datasource and a method on the form formDatasource.modified(). So I’ve overriden the method modified() on the form datasource. I’m trying to update one field of this datasource table and then call some method:

MyTable.Completed = NoYes::Yes;

method(…);

Method checks values in the table but does a mistake when reading the value of the field I updated. So basically the method() was ‘too fast’ after inserting the value in the table so it reads the old value of the field. My question is what to use between those two lines? research() is working, executeQuery() is working, updating datasource and rereading it is also working but what’s the best practice? Do I use ttscommit here? Is this even good practice to update field value from formDatasource.modified()? I need your help. Thank you in advance.

Hi,

I think the best solution would be using the modified method on the table instead of the datasource on the form.

Setting a value to a table buffer doesn’t update the record in database. It happens only if you call insert(), update() or write(). If you reread the buffer from database, your change would be lost.

Therefore you have two options:

  • let method() read the value from the same, unsaved buffer
  • save the buffer to database before calling method()

Note that saving a record in modified() is not something what users expect and it may fail, e.g. if some mandatory fields haven’t been filled in.