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 :
Microsoft Dynamics NAV (Archived)

Release sales order from code NAV 2017

(0) ShareShare
ReportReport
Posted on by 795

I Want to create a custom code unite in which it get the sales order no as a parameter and Release the sales order in NAV 2017.

Thanks in Advance 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    keoma Profile Picture
    32,729 on at

    1: precon ---

    start nav windows client

    goto "web services".

    if missing, add new entry:

    type=Page, ID=42, Name=Sales Order, ServiceName=SalesOrder, Published=yes. --> you get soap and odata urls

    2: add extension codeunit ---

    create new codeunit "Sales Lib" (with object id e.g. 50000),

    add global function "Release(Rec : record "Sales Header")"

    add this code:

    RelSalesDoc.RUN(Rec); // local variable RelSalesDoc : codeunit : 414

    EXIT(Rec.Status = Rec.Status::Released);

    3:

    create another entry in web services for the new codeunit:

    type=codeunit, id=<your cu id>, ServiceName= SalesOrder, published=NO !! (same name as above)

    4:

    create a new c# project (console appl., windows forms appl., what ever)

    add new web reference (name e.g. NavProxy) with the soap url from the newly created web service entry "SalesOrder" in nav.

    add this code:

    using System;

    using ConsoleApplication2.NavProxy;

    namespace ConsoleApplication2

    {

       class Program

       {

           static void Main(string[] args)

           {

               var client = new SalesOrder_Service();

               client.UseDefaultCredentials = true;

               var orderNo = "1010"; // assuming you have a sales order with no. = 1010

               var order = client.Read(orderNo);

               var result = client.Release(order.Key);

               Console.WriteLine("Sales order " + orderNo + " was released: " + result);

               Console.ReadLine();

           }

       }

    }

    5:

    result when running app:

    "Sales order 1010 was released: True"

  • Muhammad Arif Maseed Profile Picture
    795 on at

    2514.Capture.PNG

    sir when try to save this code unite it give this error

  • Verified answer
    keoma Profile Picture
    32,729 on at

    you need to set a return value for the function, type bool. open the local variables, goto second tab "return ...".

  • Muhammad Arif Maseed Profile Picture
    795 on at

    thank you sir that was solved now error in c# code here SalesOrder_Service();

    the type or namespace nave 'SalesOrder_Service' could not found(are you missing a using direcive or an assembly reference ?)

  • Muhammad Arif Maseed Profile Picture
    795 on at

    respected sir i am just a click away from solution please tell me how to solve this error ?

  • Verified answer
    keoma Profile Picture
    32,729 on at

    you have to add a web reference, so right click the c# projects name, select add service reference, then in the dialog click on web reference, set there the soap url of the nav web service.

  • Muhammad Arif Maseed Profile Picture
    795 on at

    sir no error but when run the code  error here   var order = client.Read(orderNo);

    error detail {"Service \"CRONUS Canada%2C Inc./Page/SalesOrder\" was not found!"}

  • Muhammad Arif Maseed Profile Picture
    795 on at

    var order = client.Read(orderNo);

    error detail {"Service \"CRONUS Canada%2C Inc./Page/SalesOrder\" was not found!"}

  • Muhammad Arif Maseed Profile Picture
    795 on at

    when run the url has change and say page not found how to solve this sir Please sir i need your help 

  • Verified answer
    keoma Profile Picture
    32,729 on at

    did you publish the sales order page in the web service list in nav. you should get there a soap url, please check that, click there on the link, you should then get an xml structure shown in the browser. this link is to be used for the web reference.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans