Hello.
I'm trying to make a report, packing list.
It has a filter "No.".
If the value of "Multi Document Package" of the record with the "No." is true,
then should list the combined orders in the same package, else list the record itself.
For the case in the below,
if filter "No." is P000130, then "Multi Document Package" value is true, so the report prints out "P000130-SO-0000508" and "P000130-SO-0000509", and their details.
If filter "No." is P000208, then "Multi Document Package" value is false, so the report print out "P000208" and its details.

I expected I can dynamically filter it in report page, but it looks not that simple.
Here is my code I expected it will work. But as you know, if statement is not allowed in dataitem.
if Multi_Document_Package then
DataItemLink = "Original Package No." = FIELD("No.");
else
DataItemLink = "No." = FIELD("No.");
Can someone give me an advise?
Thank you.
report 70705 "TRU Pckg No Packing Lst V2-T"
{
DefaultLayout = RDLC;
RDLCLayout = './RDLC/LAX SalesOrderPackingList_70704_TruTest_v0.62.rdlc';
ApplicationArea = All;
Caption = 'Pacakge Sales Orders Packing List V2 (TruTest)';
UsageCategory = ReportsAndAnalysis;
dataset
{
dataitem(PackageFilter; "LAX Package")
{
RequestFilterFields = "No.";
DataItemTableView = SORTING("Source Type", "Source Subtype", "Source ID") WHERE("Source Type" = CONST(36));
column(No_; "No.")
{
}
column(Source_ID_; "Source ID")
{
}
column(Multi_Document_No_; "Multi Document No.")
{
}
column(Multi_Document_Package;"Multi Document Package")
{
}
column(varIsMultiDocument;IsMultiDocument)
{
}
dataitem(Package; "LAX Package")
{
if Multi_Document_Package then
DataItemLink = "Original Package No." = FIELD("No.");
else
DataItemLink = "No." = FIELD("No.");
//if Multi_Document_Package then
// DataItemTableView = SORTING("Source Type", "Source Subtype", "Source ID") WHERE("Source Type" = CONST(36), "Original Package No." = CONST(FIELD("No.")));
//else
// DataItemTableView = SORTING("Source Type", "Source Subtype", "Source ID") WHERE("Source Type" = CONST(36), "Original Pa" = FILTER(FIELD("Multi Document No.")));
PrintOnlyIfDetail = true;
column(Package__Source_ID_; "Source ID")
{
}
column(Package__No__; "No.")
{
}
column(Package__Packing_Date_Caption; FieldCaption("Packing Date"))
{
}
column(Package__Source_ID_Caption; FieldCaption("Source ID"))
{
}
column(Package_Source_Subtype; "Source Subtype")
{
}
dataitem("Package Line"; "LAX Package Line")
{
DataItemLink = "Package No." = FIELD("No.");
DataItemTableView = SORTING("Package No.", "Line No.") WHERE("Quantity (Base)" = FILTER(> 0));
column(Package_Line_Type; Type)
{
}
column(Package_Line__No__; "No.")
{
}
column(Package_Line_Description; Description)
{
}
column(Package_Line_Quantity; Quantity)
{
}
column(Package_Line_Package_No_; "Package No.")
{
}
column(Package_Line_Line_No_; "Line No.")
{
}
}
trigger OnAfterGetRecord()
begin
EShipFormatAddr.PackageShipTo(ShipToAddress, Package);
end;
}
trigger OnAfterGetRecord()
begin
Package2.Reset;
Package2.SetCurrentKey("No.");
Package2.SetRange("No.", "No.");
IsMultiDocument := Package2."Multi Document Package";
strMultiDocumentNos := Package2."Multi Document No.";
end;
}
}
requestpage
{
layout
{
}
actions
{
}
}
labels
{
}
var
Package2: Record "LAX Package";
ShipToAddress: array[8] of Text[100];
PackageCount: Integer;
Sales_Order_Packing_ListCaptionLbl: Label 'Sales Order Packing List';
CurrReport_PAGENOCaptionLbl: Label 'Page';
PackageCountCaptionLbl: Label 'Total Packages';
ShipToAddress_1_CaptionLbl: Label 'Ship-to';
UOMCaptionLbl: Label 'UOM';
Package_No_CaptionLbl: Label 'Package No.';
Closed_by_Packing_StationCaptionLbl: Label 'Closed by Packing Station';
EShipFormatAddr: Codeunit "LAX EShip Format Address";
IsMultiDocument: Boolean;
strMultiDocumentNos: Text;
}