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)

Relase a sales Order from Code?

(0) ShareShare
ReportReport
Posted on by 462

Hi All,

Can anyone tell me how to release a Sales order from code. I have Navision 2016 and I created a Code unit. In my Code Unit I want to trigger the release which is located on the Sales order Page.

Thanks all,

Mohamed

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    You can use following code.

    ReleaseSalesDoc.PerformManualRelease(Rec);

    Where ReleaseSalesDoc is Codeunit "Release Sales Document" and Rec is your Sales Header Record.

    Hope this helps.

  • M.Zayed Profile Picture
    462 on at

    Thanks alot, it worked like magic :)

  • M.Zayed Profile Picture
    462 on at

    Just one last question. I am always getting this error when try to release the document from Code "There is nothing to release". But when I go to the sales order and I try to release it from the RTC its working.

    Do you have an idea why I am getting this error ?

  • Verified answer
    Community Member Profile Picture
    on at

    Do you mean that Particular Sales Order is showing error message when you try to release from code, however the same is working fine via RTC client?

    Ideally this should not happen.  

    This normally happens, when you do not have any Items or Quantity to be released for further process.

    Following is the code for such error message in CU 414.

    SalesLine.SETRANGE("Document Type","Document Type");

    SalesLine.SETRANGE("Document No.","No.");

    SalesLine.SETFILTER(Type,'>0');

    SalesLine.SETFILTER(Quantity,'<>0');

    IF NOT SalesLine.FIND('-') THEN

     ERROR(Text001,"Document Type","No.");

    Text001 - There is nothing to release for %1 %2.

  • M.Zayed Profile Picture
    462 on at

    This is exactly were the error is coming (IF NOT SalesLine.FIND('-') THEN).

    The Problem is that Navision set a filter on Sales line "Document Type" = Quote! And usually all my created sales line have type order.

    Why the manual release function looks only for Sales lines Type = Quote?  Should not it look for type = Order?

  • Verified answer
    M.Zayed Profile Picture
    462 on at

    One comment I am Releasing in another company and this is my code:

    SalesHeaderRec.CHANGECOMPANY('Company 2');    

    SalesHeaderRec.GET(SalesHeaderRec."Document Type"::Order,SalesHeaderRecNo);

    ReleaseSalesDocument.PerformManualRelease(SalesHeaderRec);

    THANKS ALOT , I solved the issue, I just had to Change the company for the Sales line record before I release. So now everything is fine :)

  • Muhammad Arif Maseed Profile Picture
    782 on at

    M Zayed sir can you please share the code i also need this code

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)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans