Unable to update field data value from one table to another table

Hi all,

I have extended my Purchase Header table and Page to include Job No. and Job Description fields and what I need is when I pick the Job No on the Purchase Header page, my custom fields on Job page should be updated the vendor no and Vendor name from the Purchase order. I have put all my code inside OnValidate trigger but immediately I pick the job no and description on my Purchase Order page and save, my job card window fields are not updated. Below is the extract of my code.

field(200; “ProjNo.”; Text[30])
{

Caption = ‘Project Number’;

DataClassification = ToBeClassified;
TableRelation = Job.“No.”;

trigger OnValidate()

var
JobHeader: Record 167;

begin

JobHeader.Get(“ProjNo.”);
“Project Name” :=JobHeader.Description;

if “Project Name” = JobHeader.Description then
begin
JobHeader.Reset();
JobHeader.SetRange(“No.”,“ProjNo.”);
if JobHeader.FindLast then
//Repeat
if JobHeader.“Consultant”= ‘’ then
JobHeader.Contractor:=“No.”;
Jobheader.Consultant:=“Buy-from Vendor Name”;

end;

end;

}

Kindly assist to sort this.

You are saying Jobheader.findlast and are you sure that in the last record you have a valid ProjNo, if not it will find a blank last record and will not update any values also even if you find you need the code Jobheader.MODIFY which is missing in your code.

Thanks so much for your response. Yeah I have missed Jobheader.MODIFY. Should I used find last or Find first.

Kindly advice.

You should use findfirst which will give you a valid match.