Codeunit.Run no working when triggered from event subscriber

samantha73samantha73 Member Posts: 111
Hi All
I have a requirement to copy fields from one record to another - not a simple copy so cannot use transferfields. Something like sales order to Sales Invoice transfer of fields. I'm finding it difficult find a trigger for below

[EventSubscriber(ObjectType::Table, Database::"Service Item Line", OnAfterValidateEvent, My FIeld, false, false)]
local procedure TransferToCalibrationHeader(var Rec: Record "Service Item Line"; var xRec: Record "Service Item Line")
.....
if not Codeunit.Run(Codeunit::MyCodeunit, Rec) then begin

this works if I run same codeunit to run from the page action as opposed to event sub which hints that something to do with transaction locking or values not full committed etc issue. Is there a better way to capture a event when everything is committed. We cannot ask the user to trigger this like sales-post or job queue as we need immediate access to the copied record. How do others deal with this kind of situation?
Sign In or Register to comment.