table 50148 "Bank Securities" { DataClassification = ToBeClassified; fields { field(50000; "Entry No"; Integer) { DataClassification = ToBeClassified; } field(50011; "Job No."; Code[20]) { DataClassification = ToBeClassified; TableRelation = Job.No.; } field(50012; "Bill-to Customer No."; Code[20]) { DataClassification = ToBeClassified; TableRelation = Job.Bill-to Customer No.; } } keys { key(PK; "Entry No", "Job No.") { Clustered = true; } } var myInt: Integer; trigger OnInsert() var recBankSec: Record "Bank Securities"; EntryNo: Integer; recJob: Record Job; begin Clear(recBankSec); Clear(EntryNo); IF recBankSec.FindLast() then EntryNo := recBankSec."Entry No" + 1 else EntryNo := 1; Rec."Entry No" := EntryNo; recJob.SetFilter("No.", rec."Job No."); IF recJob.FindFirst() then begin Rec."Bill-to Customer No." := recJob."Bill-to Customer No."; end; end; }
page 50149 "Bank Securities" { PageType = Card; ApplicationArea = All; UsageCategory = Administration; SourceTable = "Bank Securities"; RefreshOnActivate = true; layout { area(Content) { group("Bank Security") { field("Job No."; "Job No.") { ApplicationArea = All; } field("Bill-to Customer No."; "Bill-to Customer No.") { ApplicationArea = All; Editable = false; } } } actions { area(Processing) { /* action(ActionName) { ApplicationArea = All; trigger OnAction() begin end; } */ } } }
Answers
My suggestion would be to move that code to the OnValidate trigger of "Job No." field.