I've written the below codeunit with the goal of updating all Planning Line's "Planning Date" values whenever the related Jobs "Starting Date" value changes. Why is the Planning Date field not updating?
// Codeunit Source
codeunit 50102 UpdatePlanningLines
{
procedure ByJobStartDate(Job: Record Job)
begin
PlanningLines.SetRange("Job No.", Job."No.");
if PlanningLines.FindSet() then
repeat
Message('Looping task ' PlanningLines."Job Task No." ' and setting Planning Date to ' Format(Job."Starting Date"));
PlanningLines."Planning Date" := Job."Starting Date";
until PlanningLines.next = 0;
end;
var
PlanningLines: Record "Job Planning Line";
}
//On Job Card
modify("Starting Date")
{
trigger OnAfterValidate()
begin
if Rec."Starting Date" <> 0D then begin
UpdatePlanningLines.ByJobStartDate(Rec);
end;
end;
}