[Nav 2016] Problems with xRec.Status

pjungpjung Member Posts: 6
edited 2016-04-28 in NAV Three Tier
Hello,

i want to check if the status has been changed with this code below
[EventSubscriber] Warehouse Shipment Header.OnBeforeModify.Event(VAR Rec : Record "Warehouse Shipment Header";VAR xRec : Record "Warehouse Shipment 
IF (xRec.Status <> Rec.Status) THEN BEGIN
    ...
END;

But xRec.Status and Rec.Status has always the same value.
Other Fields of this recs are different but not the status?
Is this an issue or do I missunterstand something?

Best Answer

Answers

  • parmparm Member Posts: 49
    Hi,
    I think that xRec only have the previous values on Pages (or forms).
    The events may not have the previous values.

    Regards,

    parm
  • pjungpjung Member Posts: 6
    I don't thinkos so because other fields (for example User Id) has the previous value
  • postsauravpostsaurav Member Posts: 708
    Hi,

    Give it a try -
    Instead of subscribing OnBeforeModify.Event, try subscribing OnAfterModify.Event.

    Before Modify Both values will be same right?

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • pjungpjung Member Posts: 6
    Before Modify Both values will be same right?
    Yes
    Instead of subscribing OnBeforeModify.Event, try subscribing OnAfterModify.Event.
    After Modify are the vaules the same, too
  • postsauravpostsaurav Member Posts: 708
    Which NAV 2016 CU are you using?

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • pjungpjung Member Posts: 6
    Cumulative update 3 for Microsoft Dynamics NAV 2016
  • pjungpjung Member Posts: 6
    No one has an idea?
  • Peter+is1Peter+is1 Member Posts: 174
    Hi,

    a- The Warehouse Shipment Header.OnModify() itself does not modify the Status so OnBeforeModify and OnAfterModify are the same for this field.

    b- Could it be the Status changes are never followed by a Modify(TRUE); statement? (Use the Runtrigger)

    Good luck.
    \\
    The truth exists in seven versions.
  • pjungpjung Member Posts: 6
    a- OnBeforeModify and OnAfterModify have different states, so i think it will be modified.

    b- The run trigger doesn't matter my code. Because i want only to check the state and i do not check the run trigger.
    So it my code will always run if the event will be triggered.
  • Peter+is1Peter+is1 Member Posts: 174
    Hi,

    Let me try to explain in different words.

    In the Warehouse Shipment Header.OnModify() trigger in the table the Status Field is not changed.
    Because there is no code in OnModify that changes the Status Field:

    Code in Table 7320:
    OnInsert()...

    OnModify()

    OnDelete()...


    Can you find anywhere in NAV where the Status Field is changed followed by an Rec.Modify() statement?
    If not, then you cannot test for a Status Field change in the OnBeforeModify or OnAfterModify events.

    I hope this explains it better.
    \\
    The truth exists in seven versions.
Sign In or Register to comment.