RE: How to add data item on report extension
Hi,
Since the Reservation entry is linked to a Sales line, and Sales Line has a composite key (meaning multiple fields form its key), you will need to link the Reservation entry by Source ID but also by Source Ref No (see below).
addlast("Sales Line")
{
dataitem("Reservation Entry"; "Reservation Entry")
{
DataItemLink = "Source ID" = FIELD("Document No."), "Source Ref No" = FIELD("Line No.");
column(Lot_No_1; "Lot No.")
{
}
}
}
Finally, on the report layout, you will need to create a new group underneath but inside your Sales Line group as you might have one or more Lots per sales line.
If you truly want an alternative, although less elegant, you can use a variable to store the lot numbers as 1 string of the reservation entries you iterate through with a loop. Make sure to reset this variable. You can also add a breakpoint if you want to debug this. See the code below:
dataset
{
add(Line)
{
column(Lot_No_1; LotNos)
{
}
}
modify(Line)
{
trigger OnAfterAfterGetRecord()
var
ResEntry: record "Reservation Entry";
begin
LotNos := '';
ResEntry.SetFilter("Source ID", Line."Document No.");
ResEntry.SetFilter("Source Ref. No.", format(Line."Line No."));
if ResEntry.findset() then
repeat
LotNos := LotNos + ResEntry."Lot No." + ", ";
until ResEntry.next()=0;
end;
}
}
var
LotNos: text;
Hope this helps!
Sabina
Developer at LIDD Consultants