web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Sales Order

(0) ShareShare
ReportReport
Posted on by 127

Hi Friends

I'm very new to NAV.  I have to Create a Sales order using Sales header and line table in C/AL code.

Have to Create a Sales order for salespersons to calculate their Commission % based on profit %.

Even I don't have idea about this. So please Clearly tell about how to create a Sales order using C/AL code.

Thanks in Advance.

*This post is locked for comments

I have the same question (0)
  • Hannes Holst Profile Picture
    5,767 on at

    Hi,

    Are you sure it's a Sales Order? Because when using Sales Orders you are expecting to receive money.
    When you have to pay, you normally use a Purchase Order.
    In general, you should consider to read a book about development in NAV first.

    Below code-structure can be used for Purchase Orders too.

    SalesHeader.INIT;
    SalesHeader.VALIDATE("Document Type", SalesHeader."Document Type"::Order);
    SalesHeader.INSERT(TRUE); 
    
    SalesHeader.VALIDATE("Sell-to Customer No.", 'Your SalesPerson Customer No.');
    SalesHeader.MODIFY(TRUE);
    
    SalesLine.INIT;
    SalesLine.VALIDATE("Document Type", SalesHeader."Document Type");
    SalesLine.VALIDATE("Document No.", SalesHeader."No.");
    SalesLine.VALIDATE("Line No.", 10000);
    SalesLine.INSERT(TRUE);
    
    // the following depends on how you manage the comission in your system; could be a G/L Account or Item
    
    SalesLine.VALIDATE(Type, SalesLine.Type::"G/L Account"); // or SalesLine.Type::Item
    SalesLine.VALIDATE("No.", 'Your G/L Account or Item No.');
    SalesLine.Description := 'Commission';
    SalesLine.VALIDATE(Quantity, 1);
    SalesLine.VALIDATE("Unit Price", 99); // the commission
    
    SalesLine.MODIFY(TRUE);


  • Verified answer
    MadhuJaisankar Profile Picture
    127 on at

    Thank you so much Mr. Hannes Holst for your clear explanation.

  • Verified answer
    Mohsin Abbas Profile Picture
    525 on at

    Hi Madhu

    Please follow these steps to create a Sales order using C/AL:

    1- Initialize SalesHeader record.

    2- Assign values to fileds like "Sell to Customer No" using VALIDATE().

    3- Insert SalesHeader.

    4- Assign values to any other fields you want to change.

    5- Modify SalesHeader.

    6- Now initialize a SalesLine record.

    7- Assign Document type(in this case it'll be Sales Order) and Document No from the SalesHeader you just created.

    8- Assign Line no, it should be incremented by 10000 each time a new line is created. Assign No. (Item No. if you line is of type= Item)

    9- Insert SalesLine

    10- modify anyother field you want to.

    11- Repeat Steps 6-10 for all lines you need to add to the Sales order.

    Thanks.

  • MadhuJaisankar Profile Picture
    127 on at

    Thank you brother.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans