Hi,
I have an event EventSubscriber for SampleTable OnAfterInsertEvent to populate the tempSampleEnty temp table and another EventSubscriber to another Codeunit 20 (Posting Preview Event Handler) for the event "OnAfterFillDocumentEntry" to add new row in POSTING PREVIEW window but my temporary table is uninitialized or empty when Im using it in InsertDocumentEntry function.
Here is my code:
codeunit 99999 "SampleTableHandler"
{
var
tempSampleEnty : Record "Sample Table" temporary;
PostPrevHandler : Codeunit "Posting Preview Event Handler";
[EventSubscriber(ObjectType::Table, 99991, 'OnAfterInsertEvent', '', true, true)]
procedure OnInsertSampleEntry(VAR Rec: Record "SampleTable");
begin
if Rec.IsTemporary then
exit;
PostPrevHandler.PreventCommit();
tempSampleEnty := Rec;
tempSampleEnty."Document No." := '***';
tempSampleEnty.INSERT;
end;
[EventSubscriber(ObjectType::Codeunit, 20, 'OnAfterFillDocumentEntry', '', true, true)]
procedure InsertSampleDocumentEntry(VAR DocumentEntry: Record "Document Entry");
begin
PostPrevHandler.InsertDocumentEntry(tempSampleEnty, DocumentEntry);
end;
}
Thanks.