Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Add default sales line when creating Sales order

Posted on by Microsoft Employee

Hi,

When creating a new sales order i want to to be dafault set on type G/L Account and No. to 1011 (Sales Line).

I have trouble with VALIDATE("No.", '1011); (Sales Line)

Because at the time I VALIDATE i dont have the Sales Header created and I get into this with the debugger running.

8637.Udklip2.PNG

I have tried to set the trigger code various places such as, Page 46 Sales Order Subform - OnNewRecord, Sales Line, Sales Header.

Where is the correct place to have the validate for No. (Sales Line).

Thanks In advance.

*This post is locked for comments

  • Suggested answer
    dkatson Profile Picture
    dkatson 2,263 on at
    RE: Add default sales line when creating Sales order

    I would suggest you not to modify this standard code, but to use sales quote for that, and create sales orders from there.

    Or to create sales order (as template) and copy it to you new sales orders

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Add default sales line when creating Sales order

    You cannot create a new sales line by using the OnInsert trigger of the sales header, since the record is not in the database yet the validation of sales line no. will get error as you mentioned above, the best place for you to add the code is on Page 42 Sales Order on the SellToCustomerNoAfterValidate function but before adding the code of salelines insert you need to add

    the following statements to commit the salesheader.

     CurrPage.SAVERECORD;

     COMMIT;

    Then add the Sales Line Insert Code.

  • Suggested answer
    Amol Salvi Profile Picture
    Amol Salvi 18,694 on at
    RE: Add default sales line when creating Sales order

    OnInsert is best trigger to insert default values

  • Suggested answer
    Maneesha Profile Picture
    Maneesha 5,889 on at
    RE: Add default sales line when creating Sales order

    hi

    as other members suggest its full fill your requirement using  OnInsert Trigger

  • Suggested answer
    Yogesh Kulkarni_ Profile Picture
    Yogesh Kulkarni_ 1,762 on at
    RE: Add default sales line when creating Sales order

    As per your description, you can write your code on OnInsert trigger of Sales Header Table.

    But, do you mean to say that you want to set Type as G/L Account and No. as 1011 for every Sales Order?

     

    -Yogesh Kulkarni
    Please verify, if you find answer helpful.

  • Suggested answer
    Rajasekhar@MS Profile Picture
    Rajasekhar@MS 5,567 on at
    RE: Add default sales line when creating Sales order

    Hi

    You can write code OnInsert Trigger of Sales Header Table.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans