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

Field Validation not working in business central

(1) ShareShare
ReportReport
Posted on by 305
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
    95,761 Super User 2025 Season 2 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
    305 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
    885 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,005 Super User 2025 Season 2 on at
    can you share the oninsert code?
  • Test user Profile Picture
    305 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

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,126

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 744 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 674 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans