Skip to main content

Notifications

Announcements

No record found.

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
    YUN ZHU Profile Picture
    82,747 Super User 2025 Season 1 on at
    RE: Why is my Codeunit to update PlanningLine dates failing?

    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

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Why is my Codeunit to update PlanningLine dates failing?

    Solved it - Needed to finish off REPEAT iteration with:

    PlanningLines.Modify();

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
YUN ZHU Profile Picture

YUN ZHU 448 Super User 2025 Season 1

#2
Sagar Dangar, MCP Profile Picture

Sagar Dangar, MCP 358

#3
Mansi Soni Profile Picture

Mansi Soni 327

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans