Skip to main content

Notifications

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

Auto fill on insert

Posted on by 171

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!

  • AntonisK Profile Picture
    AntonisK 171 on at
    RE: Auto fill on insert

    Thank you both!!

  • Verified answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: Auto fill on insert

    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

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Auto fill on insert

    Hi,

    Please use only like this

    Insersaleslines.validate(Quantity,1);

    Insersaleslines.insert(true);

    rest leave on the system

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans