RE: Attachments General Journals
Hi, This can be added by customization.
Below is an example of a single key.
https://yzhums.com/11177/
For the case of multiple primary keys such as General Journals, I have done a test, hope the following can give you some hints.
Add attachments to vendor bank account card.
ageextension 50111 VendorBankAccountCard extends "Vendor Bank Account Card"
{
actions
{
addfirst(Processing)
{
action(DocAttach)
{
ApplicationArea = All;
Caption = 'Attachments';
Image = Attach;
ToolTip = 'Add a file as an attachment. You can attach images as well as documents.';
trigger OnAction()
var
DocumentAttachmentDetails: Page "Document Attachment Details";
RecRef: RecordRef;
begin
RecRef.GetTable(Rec);
DocumentAttachmentDetails.OpenForRecRef(RecRef);
DocumentAttachmentDetails.RunModal();
end;
}
}
}
}
codeunit 50101 DocumentAttachment2
{
[EventSubscriber(ObjectType::Page, Page::"Document Attachment Factbox", 'OnBeforeDrillDown', '', false, false)]
local procedure OnBeforeDrillDown(DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef);
var
VendorBankAccount: Record "Vendor Bank Account";
begin
case DocumentAttachment."Table ID" of
DATABASE::"Vendor Bank Account":
begin
RecRef.Open(DATABASE::"Vendor Bank Account");
if VendorBankAccount.Get(DocumentAttachment."No.") then
RecRef.GetTable(VendorBankAccount);
end;
end;
end;
[EventSubscriber(ObjectType::Page, Page::"Document Attachment Details", 'OnAfterOpenForRecRef', '', false, false)]
local procedure OnAfterOpenForRecRef(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef; var FlowFieldsEditable: Boolean);
var
FieldRef: FieldRef;
RecNo: Code[20];
VendorBankCode: Code[20];
begin
case RecRef.Number of
DATABASE::"Vendor Bank Account":
begin
FieldRef := RecRef.Field(1);
RecNo := FieldRef.Value;
DocumentAttachment.SetRange("No.", RecNo);
FieldRef := RecRef.Field(2);
VendorBankCode := FieldRef.Value;
DocumentAttachment.SetRange("Vendor Bank Number", VendorBankCode);
FlowFieldsEditable := false;
end;
end;
end;
[EventSubscriber(ObjectType::Table, Database::"Document Attachment", 'OnAfterInitFieldsFromRecRef', '', false, false)]
local procedure OnAfterInitFieldsFromRecRef(var DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef)
var
FieldRef: FieldRef;
RecNo: Code[20];
VendorBankCode: Code[20];
begin
case RecRef.Number of
DATABASE::"Vendor Bank Account":
begin
FieldRef := RecRef.Field(1);
RecNo := FieldRef.Value;
DocumentAttachment.Validate("No.", RecNo);
FieldRef := RecRef.Field(2);
VendorBankCode := FieldRef.Value;
DocumentAttachment.Validate("Vendor Bank Number", VendorBankCode);
end;
end;
end;
}
tableextension 50100 DocumentAttachmentExt extends "Document Attachment"
{
fields
{
field(50100; "Vendor Bank Number"; Code[20])
{
DataClassification = CustomerContent;
}
}
}
As for the solution, you can also refer to the Attachments button in Sales Order Subform page ( Sales line also contains multiple primary keys). Of course this requires some modification.
Hope this will help.
Thanks.
ZHU