Options

CU1 - OnDatabaseModify - Changed fields

EvREvR Member Posts: 178
Hi all,

Is there a mechanism to check if a certain field has changed value in the OnDatabaseModify function of CU1?
There is no 'xRecRef' like there is in the OnDatabaseRename.

Gr, Erik

Comments

  • Options
    vaprogvaprog Member Posts: 1,123
    Hi Erik

    doesn't Change Log do exactly this? Why not quickly peek there?

    In a nutshell: GET the record from the database, then compare it to the parameter. The one from the database is the old one, the one in the parameter the new one.
  • Options
    DuikmeesterDuikmeester Member Posts: 304
    edited 2015-11-16
    There is a hidden xRecRef in the OnDatabaseModify of Codeunit 1. If you add the parameter it will work as expected. This was fixed in KB374907 for NAV2015.
    OnDatabaseModify(RecRef : RecordRef;xRecRef : RecordRef)
    
  • Options
    EvREvR Member Posts: 178
    vaprog wrote: »
    Hi Erik

    doesn't Change Log do exactly this? Why not quickly peek there?

    In a nutshell: GET the record from the database, then compare it to the parameter. The one from the database is the old one, the one in the parameter the new one.

    I would prefer not to do a GET while in the middle of a transaction for the same record. I can already see the locking nightmares :smile:

    There is a hidden xRecRef in the OnDatabaseModify of Codeunit 1. If you add the parameter it will work as expected. This was fixed in KB374907 for NAV2015.
    OnDatabaseModify(RecRef : RecordRef;xRecRef : RecordRef)
    

    That would be awesome. I'm working with 2016RTM and the OnDatabaseModify does not have the xRecRef parameter. I'll add it tonight and let you know if it works in 2016.
  • Options
    vaprogvaprog Member Posts: 1,123
    EvR wrote: »
    I would prefer not to do a GET while in the middle of a transaction for the same record. I can already see the locking nightmares :smile:
    Why would that be a problem? If you are the one who locked it you are allowed to retrieve it. If someone else locked it, MODIFY will fail anyway.

    As I said, NAV standard Change Log does it this way.

    Obviously, if you are able to get the same information as a parameter, all the better.
Sign In or Register to comment.