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)

Change status

(0) ShareShare
ReportReport
Posted on by

I need to create An error which prevents a user from changing the status of a production order (Firm planned -> Released) If all the SYS parts aren't all completely picked.  This is an example of what I mean. 

41.PNG

42.PNG

Any feedback would be appreciated! 

*This post is locked for comments

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

    Try to write some code first at your end. If you face any difficulties, we are here.

  • Suggested answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    You can try this on Page 99000829 - Firm Planned Prod. Order, "Change Status" Action before the standard code gets called.

    **************

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

    IF ProdOrderComponents.FINDSET THEN

    BEGIN

     REPEAT

       IF ProdOrderComponents."Qty Picked" > 0 THEN  // Or if you have any other fields, you can check here

         ERROR('The Prod. Order Lines has not been fully picked.'); //Customize your error message

     UNTIL ProdOrderComponents.NEXT = 0

    END;

    ************

    ProdOrderComponents is table 5407. Please understand this isn't the full implementation, but a skeleton.

    Hope it helps.

  • Community Member Profile Picture
    on at

    Thank you! by taking that code above I need to tailor it so it only applies when the routing link code is SYS.

    Would I just write something like IF ProdOrderComponents."Routing Link Code" =  SYS THEN ...

  • Suggested answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    If you are looking at Routing Link Code =  'SYS' then you can add as a filter on top.

    **************

    ProdOrderComponents.SETFILTER(ProdOrderComponents."Routing Link Code", 'SYS');

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

    IF ProdOrderComponents.FINDSET THEN

    BEGIN

    REPEAT

      IF ProdOrderComponents."Qty Picked" > 0 THEN  // Or if you have any other fields, you can check here

        ERROR('The Prod. Order Lines has not been fully picked.'); //Customize your error message

    UNTIL ProdOrderComponents.NEXT = 0

    END;

    ************

  • Community Member Profile Picture
    on at

    Where can I put this code so that it appears once the user attempts to click Yes on this page

    43.PNG

  • Suggested answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    If you want to check after user says Yes, you probably want to code in Codeunit 5407, Prod. Order Status Management. But this codeunit manages all the Status Management regarding Production Order. Please do test all your scenarios before deploying it.

    Check the screenshot. Insert the code as shown.

    lol.PNG

    Hope it helps.

  • Community Member Profile Picture
    on at

    Thank you for your help. I've inserted this code into where you stated. When I run it through Nav I get the Confirm Box as I should but when I clock yes / no it keeps appearing. I have to spam click it to get stop it appearing. How do I fix this? 

  • Verified answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    Please attach the screenshot og your code. As per the definition, This code only fires when you press Yes. Thats the whole purpose of having ACTION::Ok.

    Hope it helps.

  • Community Member Profile Picture
    on at

    I figured it out

  • Suggested answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi,

    I was under the impression of you need to raise an Error with particular line details. If you are using confirmation boxes then the code can be simplified.

    ******************

    ProdOrderComponents.SETFILTER(ProdOrderComponents."Routing Link Code", 'SYS');

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

    ProdOrderComponents.SETFILTER(ProdOrderComponents."Qty. Picked", '>0');

    ProdOrderComponents.SETFILTER(ProdOrderComponents."Qty. Picked (Base)", '>0');

    IF ProdOrderComponents.FINDSET THEN

    BEGIN

      IF CONFIRM('Prod. Order is not fully picked', FALSE) THEN

         EXIT;

    END;

    ******************

    Try this code, and its bettter to have before ChangeStatusForm.ReturnPostingInfo(NewStatus,NewPostingDate,NewUpdateUnitCost); <- this line.

    Hope it 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

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