web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Why is my Codeunit to update PlanningLine dates failing?

(0) ShareShare
ReportReport
Posted on by

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;
}

  • Suggested answer
    Community Member Profile Picture
    on at

    Solved it - Needed to finish off REPEAT iteration with:

    PlanningLines.Modify();

  • Suggested answer
    YUN ZHU Profile Picture
    103,132 Super User 2026 Season 2 on at

    Hi, as Wolfind mentioned, you need to use Record.Modify([Boolean]) Method here.

    pastedimage1647389931842v1.png

    In addition, if you are all modified to be the same date, please consider using the ModifyAll method, this will not require a loop

    pastedimage1647390006175v2.png

    More details:

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-insert-modify-modifyall-delete-and-deleteall-methods

    Hope this will help.

    Thanks.

    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 674 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 362 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 359 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans