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)

Deleting Finished Production Orders 2013

(0) ShareShare
ReportReport
Posted on by 1,042

Has there been a change to the software (2013) that now allows you to delete a finished Production Order, even if there are Item Ledger Entries associated with it?  It didn't let you do this previously but, now it seems that it does.  Is this a bug or "by design"?  

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,001 Super User 2025 Season 2 on at

    You are right.

    I don't know 100% whether it is a bug or bydesign.

    Earlier code was:

    IF Status IN [Status::Released,Status::Finished] THEN BEGIN

     ItemLedgEntry.SETCURRENTKEY("Prod. Order No.");

     ItemLedgEntry.SETRANGE("Prod. Order No.","No.");

     IF ItemLedgEntry.FIND('-') THEN

       ERROR(

         Text000,

         Status,TABLECAPTION,"No.",ItemLedgEntry.TABLECAPTION);

     CapLedgEntry.SETCURRENTKEY("Prod. Order No.");

     CapLedgEntry.SETRANGE("Prod. Order No.","No.");

     IF CapLedgEntry.FIND('-') THEN

       ERROR(

         Text000,

         Status,TABLECAPTION,"No.",CapLedgEntry.TABLECAPTION);

    END;

    IF Status = Status::Released THEN BEGIN

     PurchLine.SETCURRENTKEY(

       "Document Type",Type,"Prod. Order No.","Prod. Order Line No.","Routing No.","Operation No.");

     PurchLine.SETRANGE("Document Type",PurchLine."Document Type"::Order);

     PurchLine.SETRANGE(Type,PurchLine.Type::Item);

     PurchLine.SETRANGE("Prod. Order No.","No.");

     IF PurchLine.FIND('-') THEN

       ERROR(

         Text000,

         Status,TABLECAPTION,"No.",PurchLine.TABLECAPTION);

    END;

    New Code is

    IF Status = Status::Released THEN BEGIN

     ItemLedgEntry.SETCURRENTKEY("Order Type","Order No.");

     ItemLedgEntry.SETRANGE("Order Type",ItemLedgEntry."Order Type"::Production);

     ItemLedgEntry.SETRANGE("Order No.","No.");

     IF ItemLedgEntry.FINDFIRST THEN

       ERROR(

         Text000,

         Status,TABLECAPTION,"No.",ItemLedgEntry.TABLECAPTION);

     CapLedgEntry.SETCURRENTKEY("Order Type","Order No.");

     CapLedgEntry.SETRANGE("Order Type",CapLedgEntry."Order Type"::Production);

     CapLedgEntry.SETRANGE("Order No.","No.");

     IF CapLedgEntry.FINDFIRST THEN

       ERROR(

         Text000,

         Status,TABLECAPTION,"No.",CapLedgEntry.TABLECAPTION);

    END;

    IF Status IN [Status::Released,Status::Finished] THEN BEGIN

     PurchLine.SETCURRENTKEY(

       "Document Type",Type,"Prod. Order No.","Prod. Order Line No.","Routing No.","Operation No.");

     PurchLine.SETRANGE("Document Type",PurchLine."Document Type"::Order);

     PurchLine.SETRANGE(Type,PurchLine.Type::Item);

     PurchLine.SETRANGE("Prod. Order No.","No.");

     IF PurchLine.FINDFIRST THEN

       ERROR(

         Text000,

         Status,TABLECAPTION,"No.",PurchLine.TABLECAPTION);

    END;

  • Suggested answer
    Miguel Llorca Gómez Profile Picture
    7,019 User Group Leader on at

    I think that the change is by design... in the same way that you can delete a posted sales invoice :-)

  • Suggested answer
    DMV Profile Picture
    1,042 on at

    Well, that does seem to be by design.  Thanks!

  • Suggested answer
    DMV Profile Picture
    1,042 on at

    Does seem like it -- of course neither one of those seems like a good idea!  

    Thanks!

  • DMV Profile Picture
    1,042 on at

    So, is there any way to restrict the users from doing this via permissions?  It's not it's own table like posted sales invoice so, can this be done in security or would we need to modify the code?  

  • Verified answer
    Mohana Yadav Profile Picture
    61,001 Super User 2025 Season 2 on at

    If you want to stop deleting if there are entries then you can use same old code.

  • Community Member Profile Picture
    on at

    Can you delete more than once at a time?

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