[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;
OnRun() Bin.GET('BLUE','A1'); Bin.Description := FORMAT(CURRENTDATETIME); Bin.MODIFY; LOCAL [EventSubscriber] BinOnBeforeModify(VAR Rec : Record Bin;VAR xRec : Record Bin;RunTrigger : Boolean) xRec.GET(Rec."Location Code",Rec.Code); MESSAGE('xRecBeforeModifyEvent: '+xRec.Description+'\'+'RecBeforeModifyEvent: '+Rec.Description); LOCAL [EventSubscriber] BinOnAfterModify(VAR Rec : Record Bin;VAR xRec : Record Bin;RunTrigger : Boolean) //xRec.GET(Rec."Location Code",Rec.Code); MESSAGE('xRecAfterModifyEvent: '+xRec.Description+'\'+'RecAfterModifyEvent: '+Rec.Description);
Answers
I think that xRec only have the previous values on Pages (or forms).
The events may not have the previous values.
Regards,
parm
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
After Modify are the vaules the same, too
Thanks & Regards,
Saurav Dhyani
Do you Know this About NAV?
Connect - Twitter | Facebook | Google + | YouTube
Follow - Blog | Facebook Page | Google + Page
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.
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.
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.
Raja Venkat
https://beginnersnav.blogspot.in/
And you can even trick the system and do it in the OnAfterModify event if you have another event subscriber get the xRec OnBeforeModify and DON'T get it in your OnAfterModify event subscriber.
Try something like this: