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...
Answered

Field Validation not working in business central

(1) ShareShare
ReportReport
Posted on by 321
Hi Guys,
I am facing one query . i.e. 
For e.g. I have one field Req.Delivery Date on sales header.& same field on sales line. once i enter data into header field it will automatically populate into sales line field.
I have write this code. code is right as per my assuption, but it is not working.
Once i select the new line ,then it will not updating that value.i want to update this field
I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    98,859 Super User 2026 Season 1 on at
    This is because your code only exists in the OnValidate trigger of Req.Delivery Date field. When you add new Sales Line, the trigger of this field is not executed.
    I think you need to add similar logic in the Sales Line's OnInsert (Table) Trigger. This should solve the problem.
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    Judy Profile Picture
    Microsoft Employee on at
    Hi Sir,
     
    It is high recommended that you can troubleshoot in the AL code to identify the root cause of the issue, you can set up break points in the specific lines.
     
    Best Regards,
    Judy
  • Test user Profile Picture
    321 on at
    Hi Yunzhu,
    I have write the same logic on insert trigger on sales line table, but still is not working. Is any other way to do this?
  • Suggested answer
    Robert Jolliffe Profile Picture
    890 on at
    This looks wrong
     

     
    Should be Rec_SalesLine."Req.Delivery Date" as "Req. Delivery Date" is referring to Rec."Req. Delivery Date" 
     
    I think you're setting the header to itself.
  • Suggested answer
    Mohana Yadav Profile Picture
    61,202 Super User 2026 Season 1 on at
    can you share the oninsert code?
  • Test user Profile Picture
    321 on at
    Hi Mohana,
    This is the code i have written on insert trigger on sales line table.
  • Suggested answer
    DevZubair Profile Picture
    4 on at
    use this code on onInsert trigger of sales Line Table and then execute
     
    trigger OnInsert()
    var
    SalesHeader: Record "Sales Header";
    begin
    SalesHeader.Get("Document Type", "Document No.");
    "My Field" := SalesHeader."My Field";
    end;

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,682 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,001 Super User 2026 Season 1

#3
Kamal Khakhkhar Profile Picture

Kamal Khakhkhar 610

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans