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 213
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
  • Suggested answer
    DevZubair Profile Picture
    4 on at
    Field Validation not working in business central
    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;
  • Nil@@m Profile Picture
    213 on at
    Field Validation not working in business central
    Hi Mohana,
    This is the code i have written on insert trigger on sales line table.
  • Suggested answer
    Mohana Yadav Profile Picture
    60,199 Super User 2025 Season 1 on at
    Field Validation not working in business central
    can you share the oninsert code?
  • Suggested answer
    Robert Jolliffe Profile Picture
    859 on at
    Field Validation not working in business central
    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.
  • Nil@@m Profile Picture
    213 on at
    Field Validation not working in business central
    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
    Judy Profile Picture
    Microsoft Employee on at
    Field Validation not working in business central
    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
  • Verified answer
    YUN ZHU Profile Picture
    78,989 Super User 2025 Season 1 on at
    Field Validation not working in business central
    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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,110 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,886 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans