Options

Change log on Sales Header / Shipment Date

fredefrede Member Posts: 80
Hi all experts and Navision Freaks...

I have this funny question:

Why does the Change Log work when changing "Shipment Date" but saying "No" to the update of sales lines.

But it does NOT work, when the user says "Yes" to update the sales lines.

It is tested in 3.70A, 3.70B and 4.00 - with same result....

Any answers is greatly appreciated.. :?: ](*,)
Regards,

Henrik Frederiksen, Denmark

Comments

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Because the change of the "Shipment Date" has been made by hand (by entering a different value in the Shipment Date field), and the change of the Sales Line has been made by some C/AL Code.

    The Change Log only handles the changes made by human beings.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    fredefrede Member Posts: 80
    Thanx Luc,

    but the change of Shipment Date on Sales Header is made "by hand" in both cases..

    I can understand that no logging of the lines change - but not the change of the header!!
    Regards,

    Henrik Frederiksen, Denmark
  • Options
    fredefrede Member Posts: 80
    In both cases Navision should log the change of the header....! ](*,) ](*,) ](*,)
    Regards,

    Henrik Frederiksen, Denmark
  • Options
    randrewsrandrews Member Posts: 135
    Change Log Setup - may be field dosen't put there?
  • Options
    pdjpdj Member Posts: 643
    frede wrote:
    In both cases Navision should log the change of the header....! ](*,) ](*,) ](*,)
    I can only agree. The Change Log is quite often not even showing what the user directly change. The reason is that when you say yes to update the lines it does a MODIFY of the header (function UpdateSalesLines) in C/AL. This MODIFY ensures the header gets updated in the same transaction as the lines. (Actually a frequent error by many developers to forget when updating "children")

    After the transaction started by the OnValidate is finished, is the user placed back in the form. When the user press esc/page-up (etc.) the automatic update is started, that might store something in the ChangeLog. However, it will not find any differences, so it will not log anything.

    This situation MIGHT be changed by Update 1 to 4.0. I seem to remember that the logic to find xRec has been changed, but I don't know if it solves this problem.

    You can also solve the problem yourself, however you can only do it one by one. For example like this:
    UpdateSalesLines(ChangedFieldName : Text[100];AskQuestion : Boolean)
      ...
      SalesLine.LOCKTABLE;
    
      // >>
      RecRef.GETTABLE(Rec);
      xRecRef.OPEN(RecRef.NUMBER);
      xRecRef.GET(RecRef.RECORDID);
      ChangeLogManagement.LogModification(RecRef,xRecRef);
      // <<
    
      MODIFY;
      SalesLine.RESET;
      ...
    
    (Not tested, but it should work - otherwise let me know ;-))
    Regards
    Peter
  • Options
    randrewsrandrews Member Posts: 135
    pdj wrote:
    UpdateSalesLines(ChangedFieldName : Text[100];AskQuestion : Boolean)
      ...
      SalesLine.LOCKTABLE;
    
      // >>
      RecRef.GETTABLE(Rec);
      xRecRef.OPEN(RecRef.NUMBER);
      xRecRef.GET(RecRef.RECORDID);
      ChangeLogManagement.LogModification(RecRef,xRecRef);
      // <<
    
      MODIFY;
      SalesLine.RESET;
      ...
    
    (Not tested, but it should work - otherwise let me know ;-))
    xRecRef - RECORDREF
    RecRef - RECORDREF
    ChangeLogManagement - Codeunit "Change Log Management"

    Do I need to initiate ChangeLogManagement? Or 4 strings make the record in table change log entry?
  • Options
    pdjpdj Member Posts: 643
    randrews wrote:
    Do I need to initiate ChangeLogManagement? Or 4 strings make the record in table change log entry?
    The four lines should be enough. However; test it carefully before putting it in production, since my code comes with no guarantee :-)
    Regards
    Peter
  • Options
    TirtaTirta Member Posts: 53
    Hi pdj,

    your code works!
    Now I found the answer why Navision didn't log changes by field Routing No. or Production BOM No. in Table Item.

    Excellent.

    Regards
    Tirta
Sign In or Register to comment.