Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Business Central forum
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

How to get value from temporay table in Business Central Extension “AL”

Posted on by 30

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.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans