Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Change status

Posted on by Microsoft Employee

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

  • Suggested answer
    RE: Change status

    Hi Lewis,

    Try Vishal's code. It will work fine.

    Hope it helps.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Change status

    This should work fine.

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

    recProdOrderComp.SETRANGE("Routing Link Code", 'SYS');

    recProdOrderComp.SETRANGE("Qty. Picked", 0);

    IF recProdOrderComp.FINDSET THEN

     IF CONFIRM('There are SYS parts NOT picked on this Production Order. Do you wish to continue?', FALSE) = FALSE THEN

       EXIT

     Else

       Message('YES'); // Sample Code

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Change status

    The code works, however when I enter No on the confirm box it still acts as if I selected yes. Here is the code.


    recProdOrderComp.SETFILTER(recProdOrderComp."Routing Link Code", 'SYS');
    recProdOrderComp.SETRANGE(recProdOrderComp."Prod. Order No.", "No.");
    recProdOrderComp.SETFILTER(recProdOrderComp."Qty. Picked", '0');
    recProdOrderComp.SETFILTER(recProdOrderComp."Qty. Picked (Base)", '0');
    IF recProdOrderComp.FINDSET THEN
    BEGIN
    IF CONFIRM('Their are SYS parts NOT picked on this Production Order. Do you wish to continue?', FALSE) = FALSE THEN
    EXIT;
    END;

  • Suggested answer
    RE: Change status

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Change status

    I figured it out

  • Verified answer
    RE: Change status

    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
    Community Member Microsoft Employee on at
    RE: Change status

    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? 

  • Suggested answer
    RE: Change status

    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
    Community Member Microsoft Employee on at
    RE: Change status

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

    43.PNG

  • Suggested answer
    RE: Change status

    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;

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

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans