When you have groups within a grid that also have visibility using variables, it does not display correctly in BC.
I created a code to simplify the situation by following this post by Yun Zhu
https://yzhums.com/14752/
This does not work when the field “Type” initializes variables in false in the trigger OnOpenPage, being shown this way:
I leave the code that can be deployed and easily reproduced by creating a new client, in the same way as the original post.
I reiterate that this worked for years until a few months ago.
If the way to write this code is incorrect, what would be the way to achieve the same goal?
tableextension 50111 ZYCustomerExt extends Customer
{
fields
{
field(50100; "Type"; Option)
{
Caption = 'Type';
OptionMembers = " ","Car","Motorcycle","All";
DataClassification = CustomerContent;
}
field(50101; "Car Code 1"; Code[20])
{
Caption = 'Car Code 1';
DataClassification = CustomerContent;
}
field(50102; "Car Description 1"; Text[50])
{
Caption = 'Car Description 1';
DataClassification = CustomerContent;
}
field(50103; "Motorcycle Code 1"; Code[20])
{
Caption = 'Motorcycle Code 1';
DataClassification = CustomerContent;
}
field(50104; "Motorcycle Description 1"; Text[50])
{
Caption = 'Motorcycle Description 1';
DataClassification = CustomerContent;
}
}
}
pageextension 50111 ZYCustomerCardExt extends "Customer Card"
{
layout
{
addafter(Name)
{
field(Type; Rec.Type)
{
ApplicationArea = All;
trigger OnValidate()
begin
InitializeVariables();
end;
}
group(CategoriesGroup)
{
Visible = Car1Visible or Motorcycle1Visible;
ShowCaption = false;
grid(grid)
{
group(Names)
{
ShowCaption = false;
group(CarCode)
{
Visible = Car1Visible;
ShowCaption = false;
field("Car Code"; Rec."Car Code 1")
{
ApplicationArea = All;
}
}
group(MotorcycleCode)
{
Visible = Motorcycle1Visible;
ShowCaption = false;
field("Motorcycle Code 1"; Rec."Motorcycle Code 1")
{
ApplicationArea = All;
}
}
}
group(Descriptions)
{
ShowCaption = false;
group(CarDescription)
{
Visible = Car1Visible;
ShowCaption = false;
field("Car Description"; Rec."Car Description 1")
{
ApplicationArea = All;
}
}
group(MotorcycleDescription)
{
Visible = Motorcycle1Visible;
ShowCaption = false;
field("Motorcycle Description 1"; Rec."Motorcycle Description 1")
{
ApplicationArea = All;
}
}
}
}
}
}
}
trigger OnOpenPage();
begin
InitializeVariables();
end;
var
Car1Visible, Motorcycle1Visible : Boolean;
local procedure InitializeVariables()
begin
case Rec.Type of
Rec.Type::" ":
SetFieldsVisible(false, false);
Rec.Type::Car:
SetFieldsVisible(true, false);
Rec.Type::Motorcycle:
SetFieldsVisible(false, true);
Rec.Type::All:
SetFieldsVisible(true, true);
end;
end;
local procedure SetFieldsVisible(Code1Visible: Boolean; Code2Visible: Boolean)
begin
Car1Visible := Code1Visible;
Motorcycle1Visible := Code2Visible;
end;
}