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.
Any feedback would be appreciated!
*This post is locked for comments
Hi Lewis,
Try Vishal's code. It will work fine.
Hope it helps.
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
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;
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.
I figured it out
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.
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?
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.
Hope it helps.
Where can I put this code so that it appears once the user attempts to click Yes on this page
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;
************
Sohail Ahmed
2
mmv
2
Amol Salvi
2