Creating a Log During change in Field Size

postsaurav
postsaurav Member Posts: 708
Hi all,

I was just thinking that will it be possible to create a log of Changes done in Field Size?

Let me know if it is possible.

Thanks.

Thanks & Regards,
Saurav Dhyani

Do you Know this About NAV?


Connect - Twitter | Facebook | Google + | YouTube

Follow - Blog | Facebook Page | Google + Page

Answers

  • Dakkon
    Dakkon Member Posts: 193
    If you mean to log every time there is a designer change to the data length of a code or text field, then yes, it is possible to log. If you are using a more recent version of Nav (I think 2009 is the first that supports these), you can use the new database change "triggers" (I say triggers, but technically they are just procedures the client calls) defined in Codeunit 1. You would put some C/AL code in the GetDatabaseTableTriggerSetup and OnDatabaseModify procedures. Your code would check if the record being modified is in the Object table, and then if so, log the change if the length is different. You most certainly want to do something like this in a dev system first, since messing with Codeunit 1 can lead to some serious problems from even the most minor of errors.

    Below is some example code, which I have NOT tested, so you may need to make changes. the MyLoggingCodeunit would be your custom Codeunit, of course, which would include the logic of deriving the value of the Length field, comparing it to the previous length, logging the data, etc.
    GetDatabaseTableTriggerSetup(TableId : Integer;VAR Insert : Boolean;VAR Modify : Boolean;VAR Delete : Boolean;VAR Rename : Boolean)
      IF TableId = DATABASE::Object THEN
        Modify := TRUE;
    
    OnDatabaseModify(RecRef : RecordRef)
      IF RecRef.NUMBER = DATABASE::Object THEN
        MyLoggingCodeunit.LogLengthChange(RecRef);
    
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • postsaurav
    postsaurav Member Posts: 708
    Hi,

    Thanks for the reply.

    But I doubt that we have such functions in codeunit 1 (GetDatabaseTableTriggerSetup and OnDatabaseModify).

    I am using NAV 2009 SP1 IN Database and I don't see any such triggers.

    Did I missed anything? Please suggest

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Dakkon
    Dakkon Member Posts: 193
    Ah, that is unfortunate, they were added in Nav2009 R2. Well, If you can upgrade your executables to R2, this solution should work for you.
    Thad Ryker
    I traded my sanity for a railgun :mrgreen:
  • pferreira
    pferreira Member Posts: 22
    Replicating all the new code on an older NAV 2009 would not work, would it?
    I would like to use these new database triggers, but the client version is still on 2009.

    I'm assuming the client has to "know" that these new functions exist on COD1, so I don't think that even replicating all the code on an older client version would not work. As anyone tried it?
  • vaprog
    vaprog Member Posts: 1,173
    No, it would not work. It's a new feature in 2009 R2 (platform, i.e. client executable).
  • bbrown
    bbrown Member Posts: 3,268
    What's the purpose of this modification? Not what it does, but why it's needed.
    There are no bugs - only undocumented features.