web
You’re offline. This is a read only version of the page.
close
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;
}

I have the same question (0)
  • 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
    95,748 Super User 2025 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,066

#2
YUN ZHU Profile Picture

YUN ZHU 658 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 595

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans