fields are not being updated. How can I ensure these fields are correctly updated? Below is the code and events I have subscribed to, and I have referred to
.
codeunit 50204 DocumentAttachment
{
[EventSubscriber(ObjectType::Page, Page::"Document Attachment Factbox", 'OnBeforeDrillDown', '', false, false)]
local procedure OnBeforeDrillDown(DocumentAttachment: Record "Document Attachment"; var RecRef: RecordRef);
var
Employee: Record Employees;
begin
case DocumentAttachment."Table ID" of
DATABASE::Employees:
begin
RecRef.Open(DATABASE::Employees);
Employee.SetRange(EmpID, DocumentAttachment."No.");
Employee.SetRange(EmpCode, DocumentAttachment.EmpCode);
if Employee.FindFirst() then begin
RecRef.GetTable(Employee);
end;
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
FieldRef: FieldRef;
RecNo: Code[20];
EmpCd: Code[10];
EmpTyp: Enum EmployeeType;
begin
case RecRef.Number of
DATABASE::Employees:
begin
FieldRef := RecRef.Field(1);
RecNo := FieldRef.Value;
DocumentAttachment.SetRange("No.", RecNo);
FieldRef := RecRef.Field(4);
EmpCd := FieldRef.Value;
DocumentAttachment.SetRange(EmpCode, EmpCd);
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];
EmpCd: Code[10];
EmpTyp: Enum EmployeeType;
begin
case RecRef.Number of
DATABASE::Employees:
begin
FieldRef := RecRef.Field(1);
RecNo := FieldRef.Value;
DocumentAttachment.Validate("No.", RecNo);
FieldRef := RecRef.Field(4);
EmpCd := FieldRef.Value;
DocumentAttachment.Validate(EmpCode, EmpCd);
end;
end;
end;
}