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

Auto fill on insert

(0) ShareShare
ReportReport
Posted on by 264

Greetings to all of you!

I will try to explain my question with an example:

Lets say that i want to insert a new line , through AL , in the sales line table.

If i had to do it through the interface like a normal user does, when i fill the quantity with the value 1 , the system will automatically fill the values of the relevant quantity fields.


My problem is that , if i input the line myself through code, and set the quantity of the item line to be equal to 1, the system wll not automatically fill the values of the relevant fields such as outstanding qty, qty to ship,qty to invoice e.t.c.

Due to that , i need to go myself and do it manually which is a little bit annoying.

I bet that there is a smarter way to do it that i just dont know about.

Any thoughts?

Thank you in advance lads!

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Please use only like this

    Insersaleslines.validate(Quantity,1);

    Insersaleslines.insert(true);

    rest leave on the system

  • Verified answer
    Govinda Kumar Profile Picture
    2,310 Moderator on at

    Hi, I think you should fill the values using "Validate" method. For example, you can use it like InsertSalesLines.Validate(Quantity, 1); it will execute the onValidate() trigger of that particular field. and will automatically fill in all the relevant fields that depend on the quantity, just as you mentioned you do on the user interface.

    I hope this helps you.

    Regards

  • AntonisK Profile Picture
    264 on at

    Thank you both!!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 715 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 452 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 371 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans