Hi,
I have a custom field "Comments" which is added in Posted Sales Shpt. Subform. I managed to code in AL that when field has value and it was clicked, it will open up the record and then it can be modified like the image:


So, what i wanted to achieve it that when there is no value in the field, and it is clicked, it will open up and display the list of records. I managed to display the list using the trigger OnDrillDown(), but i dont know how to set the "Comments" field when a record is selected and the button OK is clicked.


I am new to this AL but here is my OnDrillDown() trigger:
trigger OnDrillDown()
var
CommentRec: Record "Extended Comment";
CommentList: Page "Extended Comment List";
CommentPage: Page "Extended Comment Page";
begin
if Rec."Comments" <> '' then begin
CommentRec.SetFilter(Code, Rec."Comments");
CommentPage.GetRecord(CommentRec);
CommentPage.LookupMode(true);
if CommentPage.RunModal() = Action::LookupOK then
CommentPage.SaveRecord();
end else begin
CommentRec.SetRange(Code);
CommentList.GetRecord(CommentRec);
CommentList.LookupMode(true);
if CommentList.RunModal() = Action::OK then
// I dont know what codes will I add here
end;
end;