Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Relase a sales Order from Code?

Posted on by 460

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

  • RE: Relase a sales Order from Code?

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

  • Verified answer
    M.Zayed Profile Picture
    M.Zayed 460 on at
    RE: Relase a sales Order from Code?

    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 :)

  • M.Zayed Profile Picture
    M.Zayed 460 on at
    RE: Relase a sales Order from Code?

    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
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Relase a sales Order from Code?

    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
    M.Zayed 460 on at
    RE: Relase a sales Order from Code?

    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 ?

  • M.Zayed Profile Picture
    M.Zayed 460 on at
    RE: Relase a sales Order from Code?

    Thanks alot, it worked like magic :)

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Relase a sales Order from Code?

    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.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans