In the ForNAV Designer, you can add new data items to a layout without modifying the underlying AL-code. This has the benefit of easy deployment and maintenance, because the changes only exist in custom layout, which is data and not code.
Data items require temporary tables to run and custom AL-logic to fill up the table. You can do this in the ForNAV Designer by adding a new data item to a custom layout:
When the report runs, the OnForNAVFillTemporaryTable event is called (just before OnPreDataItem) to fill up the table and the data item executes like any normal data item.
The OnForNAVFillTemporaryTable event has the following parameters:
- ReportID – the number of the report.
- ChildDataItemId – the name of the virtual data item.
- ParentRecRef – a RecordRef to the parent (or sibling) data item.
- TempRefRec – a RecordRef to the temporary table to fill.
- IsHandled – set to true to disable normal ForNAV behavior.
The following example fills a VAT Amount Line temporary table with the VAT specification from the Header, which is the parent data item:
[EventSubscriber(ObjectType::CodeUnit, Codeunit::"ForNAV TempTable",'OnForNAVFillTemporaryTable', '', false, false)]local procedure OnForNAVFillTemporaryTable(ReportID: Integer;ChildDataItemId: Text; ParentRecRef: RecordRef;var TempRecRef: RecordRef ; var IsHandled: Boolean)varVATAmountLine: Record "VAT Amount Line" temporary;TestValidDociFace: Codeunit "ForNAV Test Valid Doc iFace";DocLineBuffer: Record "ForNAV Document Line Buffer" temporary;LineRec: RecordRef;beginif TempRecRef.Number = Database::"VAT Amount Line" then beginif TestValidDociFace.CheckValid(ParentRecRef) then beginFindLinesRecRef(DocLineBuffer, ParentRecRef, LineRec);TempRecRef.SetTable(VATAmountLine);CreateVATAmountLine(DocLineBuffer, VATAmountLine);TempRecRef.Copy(VATAmountLine, true);end;end;end;
Out of the box, the ForNAV Customizable Report Pack comes with an event subscriber to create Item Tracking (from ForNAV 6.3), VAT, and Sales tax specifications.
A prerequisite is that ForNAV 6.2.0.2226 and the Customizable Report Pack 6.2.0.5 or later is installed.
The post How to fill temporary tables in AL-code and use them in custom layouts appeared first on ForNAV.