Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How to add a salesOrder using httpwebrequest ?

(0) ShareShare
ReportReport
Posted on by 975

Hi expert ,

  I am able to post customer data through httpwebrequest but  not able post SalesOrder data using same process . I have define the sales order values as below format .I can't understand which values are need to be define to post a SalesOrder in nav. When i am trying to post its return 5000 internal error . Please give suggestion if i missed to define a field value which is mandatory for a salesOrder .

<ins:Create>
<ins:SalesOrder>
<ins:No>1010</ins:No>
<ins:Sell_to_Customer_No>C001</ins:Sell_to_Customer_No>
<ins:Posting_Date>2013-07-12</ins:Posting_Date>
<ins:Order_Date>2013-07-12</ins:Order_Date>
<ins:Document_Date>2013-07-12</ins:Document_Date>
<ins:Bill_to_Customer_No>C001</ins:Bill_to_Customer_No>
<ins:Currency_Code>USD</ins:Currency_Code>
<ins:UDF1>1</ins:UDF1>
<ins:SalesLines>
<ins:Sales_Order_Line>
<ins:Type>2</ins:Type>
<ins:No>ITM001</ins:No>
<ins:VAT_Prod_Posting_Group>Vat-25</ins:VAT_Prod_Posting_Group>
<ins:Description>Item one</ins:Description>
<ins:Location_Code>White</ins:Location_Code>
<ins:Unit_Price>100</ins:Unit_Price>
<ins:Quantity>2</ins:Quantity>
<ins:Line_Amount>200</ins:Line_Amount>
<ins:Qty_to_Ship>2</ins:Qty_to_Ship>
<ins:Qty_to_Invoice>2</ins:Qty_to_Invoice>
<ins:Document_No>1010</ins:Document_No>
<ins:Line_No>1000</ins:Line_No>
<ins:UDF1>1</ins:UDF1>
</ins:Sales_Order_Line>
<ins:Sales_Order_Line>
<ins:Type>5</ins:Type>
<ins:No>S-FREIGHT</ins:No>
<ins:VAT_Prod_Posting_Group>Vat-25</ins:VAT_Prod_Posting_Group>
<ins:Description>Item one</ins:Description>
<ins:Location_Code>White</ins:Location_Code>
<ins:Unit_Price>5</ins:Unit_Price>
<ins:Quantity>1</ins:Quantity>
<ins:Line_Amount>5</ins:Line_Amount>
<ins:Qty_to_Ship>1</ins:Qty_to_Ship>
<ins:Qty_to_Invoice>1</ins:Qty_to_Invoice>
<ins:Document_No>1010</ins:Document_No>
<ins:Line_No>2000</ins:Line_No>
<ins:UDF1></ins:UDF1>
</ins:Sales_Order_Line>
</ins:SalesLines>
</ins:SalesOrder>
</ins:Create>

 Thanks

Surajit

*This post is locked for comments

  • Neville Foyn Profile Picture
    Neville Foyn 4,320 on at
    RE: How to add a salesOrder using httpwebrequest ?

    Great, happy to help

  • Suggested answer
    surajitkundu Profile Picture
    surajitkundu 975 on at
    RE: How to add a salesOrder using httpwebrequest ?

    Hi Neville,

      Thank for the reply . I have done it after  creating blank header and line .

    Thanks

    Surajit

  • Verified answer
    Neville Foyn Profile Picture
    Neville Foyn 4,320 on at
    RE: How to add a salesOrder using httpwebrequest ?

    Hi

    If you leave those 2 fields blank when you insert the record the system will automatically fill them in

    For it to work though you need to create and insert the new header (Insert), then populate the header fields and modify it, then insert and populate the lines

    If you are creating everything in one go the lines wont see the header when they are inserted and you will have problems

    That is the reason why codeunits are used even though they are more work, as you have complete control over how the records are inserted

    You are correct though, adding the document and line numbers list that should work, however i think you will pick up other problems later due to this insert header first bit

    Cheers

    Nev

  • surajitkundu Profile Picture
    surajitkundu 975 on at
    RE: How to add a salesOrder using httpwebrequest ?

    Hi Neville Foyn ,

     Thanks for the reply .  If I use codeunit  for the multiple order then I need to be called updatemultiple salesorder to post salesorder using httpwebrequest.But I want to call createmultiple order .

      As per your suggestion I have changed the sort order  , now no exception but return blank format.

     Actually I have a xml file of  multiple orders and I want  to create multiple orders at a time using httpwebrequest. is there any process  that No and LineNo field automatically set if I define these fields blank?

    I have another idea that read last salesorder no from 'No series line' table then increement  that no by +1  and set that value in 'No' field and for item line-no value I will set as per the item count in sales order e.g(count is 2 then line no will 10000 and 20000).

    Thanks

    Surajit

  • Suggested answer
    Neville Foyn Profile Picture
    Neville Foyn 4,320 on at
    RE: How to add a salesOrder using httpwebrequest ?

    Hi

    There can be a few issues with posting a sales order,

    There are a lot more business rules and things need to be done in the correct sequence, personally i would suggest you rather created the order using a codeunit as that will allow you to control the creation better

    If you have to use the page,

    Go into NAV and manually capture a sales order, make note of the fields that you fill in then ensure that you write to the same fields from the web service

    I cannot remember how we sorted it out but we also had a problem where the web servce was adding the fields in the wrong order so the item number before the type, this also causes errors

    Using a codeunit is a lot simpler, create one for add sales header, returning the new SO number, then another adding lines, have your code create the header, then pass the lines with the SO number that was returned in the first bit of code

    Cheers

    Nev

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans