Updating Timestamps

Posted by Admin on 17-Sep-2009 11:54

I want to update my Last Updated timestamp field.  I choose to create an override procedure to override the commitTransaction procedure.  It works fine when I make changes and choose Save on my SmartToolBar.  The problem is if I make another change to the same record and click Save again, I get the following error window which is titled 'Data Error':

Table: Keywords

Field(s) have been changed by another user.  Your change has been rejected.

Update cancelled.

My logic just updates the timestamp, so there must be some other command I need.  Any ideas?

Paul

All Replies

Posted by Peter Judge on 17-Sep-2009 13:35

pauld wrote:

I want to update my Last Updated timestamp field.  I choose to create an override procedure to override the commitTransaction procedure.  It works fine when I make changes and choose Save on my SmartToolBar.  The problem is if I make another change to the same record and click Save again, I get the following error window which is titled 'Data Error':

Table: Keywords

Field(s) have been changed by another user.  Your change has been rejected.

Update cancelled.

My logic just updates the timestamp, so there must be some other command I need.  Any ideas?

Paul

Try setting the CheckCurrentChanged property to False before doing the update.

-- peter

Posted by Admin on 17-Sep-2009 14:07

Peter,

Thanks, that worked!

Right before I saw your reply I tried a 'RUN commitData ...' command which also worked.  Right now I'm new to ADM2 and just guessing at things.

Posted by Håvard Danielsen on 21-Sep-2009 16:08

pauld wrote:

I want to update my Last Updated timestamp field.  I choose to create an override procedure to override the commitTransaction procedure.  It works fine when I make changes and choose Save on my SmartToolBar.  The problem is if I make another change to the same record and click Save again, I get the following error window which is titled 'Data Error':

Table: Keywords

Field(s) have been changed by another user.  Your change has been rejected.

Update cancelled.

My logic just updates the timestamp, so there must be some other command I need.  Any ideas?

Paul

The reason you get this message is probably that the database change is done too late to be updated in the SDO's temp-table.  The SDO will then interprete this as a change by another user the next time you save the data.

Use the supported transaction hooks, like EndTransactionValidate, instead and the change should be copied to the SDO's temp-table. Database access in overrides is rarely necessary and generally not a good idea (with the possible exception of assignDbRow... if you know what you are doing). CommitTransaction would run on the client in an SDO that is running on an AppServer and should rather not have any database access.

Most importantly, implementing manual database changes in one of the supported transaction hooks ensures that they are done in the same transaction as the regular saved changes. If you do this in commitTransaction you risk that the timestamp is wrong if the save fails and the SDO transaction is backed out.

Posted by tdugas on 13-Oct-2010 12:14

Hi Paul,

Would you be able to tell me which "smart tool bar" you used for this?

I have been trying to do this very thing with a new window I created, but I am using the panel named "p-updateonly.w", and I cannot access the procedures for it to be able to create an override for the committTransaction procedure, so I was curious as to which toolbar or panel you are using (or if maybe you created your own, would you be able to help me figure it out?).

Thank you,

Trey Dugas

This thread is closed