Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Field Validation not working in business central

(1) ShareShare
ReportReport
Posted on by 205
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
    DevZubair 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
    Nil@@m 205 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
    Mohana Yadav 60,050 Super User 2024 Season 2 on at
    Field Validation not working in business central
    can you share the oninsert code?
  • Suggested answer
    Robert Jolliffe Profile Picture
    Robert Jolliffe 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
    Nil@@m 205 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
    Judy 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
    YUN ZHU 75,561 Super User 2024 Season 2 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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,602 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,338 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans