codeunit 50110 "Doc Attachment Handlers"
{
[EventSubscriber(ObjectType::Page, Page::"Doc. Attachment List Factbox",
'OnAfterGetRecRefFail', '', false, false)]
local procedure DocAttachmentListFactbox_OnAfterGetRecRefFail(
var Sender: Page "Doc. Attachment List Factbox";
DocumentAttachment: Record "Document Attachment";
var RecRef: RecordRef)
var
TestTable: Record "Test Table";
begin
case DocumentAttachment."Table ID" of
DATABASE::"Test Table":
begin
RecRef.Open(DATABASE::"Test Table");
if TestTable.Get(DocumentAttachment."No.") then
RecRef.GetTable(TestTable);
end;
end;
end;
[EventSubscriber(ObjectType::Table, Database::"Document Attachment",
'OnAfterInitFieldsFromRecRef', '', false, false)]
local procedure DocumentAttachment_OnAfterInitFieldsFromRecRef(
var DocumentAttachment: Record "Document Attachment";
var RecRef: RecordRef)
var
FieldRef: FieldRef;
RecNo: Code[20];
begin
case RecRef.Number of
DATABASE::"Test Table":
begin
FieldRef := RecRef.Field(1);
RecNo := Format(FieldRef.Value);
DocumentAttachment.Validate("No.", RecNo);
end;
end;
end;
}
table 50100 "Test Table"
{
DataClassification = CustomerContent;
LookupPageId = 50138;
fields
{
field(1; ID; Code[20])
{
Caption = 'ID';
DataClassification = CustomerContent;
}
field(2; Name; Text[100])
{
Caption = 'Name';
DataClassification = CustomerContent;
}
field(3; Description; Text[250])
{
Caption = 'Description';
DataClassification = CustomerContent;
}
}
keys
{
key(PK; ID)
{
Clustered = true;
}
}
}
page 50139 "Test Card"
{
PageType = Card;
SourceTable = "Test Table";
ApplicationArea = All;
Caption = 'test card';
layout
{
area(content)
{
group(General)
{
field(ID; Rec.ID) { ApplicationArea = All; }
field(Name; Rec.Name) { ApplicationArea = All; }
field(Description; Rec.Description) { ApplicationArea = All; }
}
}
area(factboxes)
{
part("Attached Documents List"; "Doc. Attachment List Factbox")
{
ApplicationArea = All;
Caption = 'Documents';
UpdatePropagation = Both;
SubPageLink = "Table ID" = const(Database::"Test Table"),
"No." = field(ID);
}
}
}
}
page 50138 "Test list"
{
PageType = List;
SourceTable = "Test Table";
ApplicationArea = All;
Caption = 'test list';
CardPageId = 50139;
layout
{
area(Content)
{
repeater(content)
{
field(ID; Rec.ID) { ApplicationArea = All; }
field(Name; Rec.Name) { ApplicationArea = All; }
field(Description; Rec.Description) { ApplicationArea = All; }
}
}
}
}