Hi, I'm new to NAV/BC development and trying to figure out how to use the onpredataitem and onaftergetrecord trigger in a report dataset. I have read the online documentation and also used the txt2al tool to look at the code used to generate some of the reports (sales invoice, detail trial balance).. I'm still having a hard time wrapping my mind around how this would work. Here is the code I'm working with, I have three tables: sales invoice header, sales invoice line and location. I am trying to figure out how to use the onpredataitem and onaftergetrecord triggers to pull the location name rather than adding another dataitem. The code I have today is below...
Thanks in advance for your help!
report 50116 "Test Report"
{
UsageCategory = Administration;
ApplicationArea = All;
RDLCLayout = 'rdl_layouts\test.rdl';
dataset
{
dataitem("Sales Invoice Header"; "Sales Invoice Header")
{
RequestFilterFields = "Document Date";
column(No_; "No.") { }
column(Document_Date; "Document Date") { }
column(Posting_Date; "Posting Date") { }
column(Sell_to_Customer_Name; "Sell-to Customer Name") { }
dataitem("Sales Invoice Line"; "Sales Invoice Line")
{
DataItemLink = "Document No." = field ("No.");
column(Item_No_; "No.") { }
column(Description; Description) { }
dataitem(Location; Location)
{
//is there a way to use an onpredataitem and onaftergetrecord trigger to pull the location name?
DataItemLink = "Code" = field ("Location Code");
column(Name; Name) { }
}
}
}
}
}
0
Answers
You can on either sales invoice header or sales invoice line add a local variable for Type Record and subtype Location.
Then onAfterGetRecord you can added code like:
Thank you! Here is where I landed... seems to be working
trigger OnAfterGetRecord()
var
slsLocation: Record Location;
begin
if not slsLocation.Get("Sales Line"."Location Code") then
clear(slsLocation) else
locationName := slsLocation.Name
end;