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)

Creating a Prod. Order

(0) ShareShare
ReportReport
Posted on by

When creating a Prod. order from a  Sales Order it currently looks at the lines and error's if there is a Prod. Bom version missing. I need to alter this to allow for creating a prod. Order from the lines even if this bom version is blank for the remaining lines and store the lines which did have a prod order missing for use in a message etc.. 

Here is the code: 


ProductionOrderHeader.VALIDATE(Status, ProductionOrderHeader.Status::Planned);
ProductionOrderHeader.VALIDATE("Source Type", ProductionOrderHeader."Source Type"::"Sales Header");
ProductionOrderHeader.VALIDATE("Source No.", "Sales Order No.");
ProductionOrderHeader.VALIDATE("No.");
ProductionOrderHeader.VALIDATE("Source Order", "Sales Order No.");
ProductionOrderHeader.VALIDATE(Quantity, Quant);

IF recSalesLine.GET(
"Sales Header"."Document Type",
"Sales Header"."No.",
"Sales Line No.") THEN BEGIN
ProductionOrderHeader.VALIDATE("Due Date", recSalesLine."Requested Delivery Date");
IF recSalesLine."Prod. BOM Version" = '' THEN // Check for a blank Version
ERROR(Text0006);
END ELSE
ProductionOrderHeader.VALIDATE("Due Date", "Sales Header"."Requested Delivery Date");

IF ProductionOrderHeader.INSERT(TRUE) THEN BEGIN
ProductionOrderApplyTemplate(ProductionOrderHeader, goptTemplate::Finished);
ProductionOrderApplyCustomerName(ProductionOrderHeader);

"PO No." := ProductionOrderHeader."No.";

ProductionOrderLine.INIT;
ProductionOrderLine.VALIDATE(Status, ProductionOrderLine.Status::Planned);
ProductionOrderLine.VALIDATE("Prod. Order No.","PO No.");
ProductionOrderLine.VALIDATE("Item No.",Item."No.");
ProductionOrderLine.VALIDATE(Quantity, Quant);
ProductionOrderLine.VALIDATE("Bin Code", InvSetup."Finished Bin Code");
ProductionOrderLine.VALIDATE("Sales Order No.", "Sales Order No.");
ProductionOrderLine.VALIDATE("Sales Order Line No.", "Sales Line No.");

ProductionOrderLine.INSERT(TRUE);

ProductionOrderPage.SETTABLEVIEW(ProductionOrderHeader);
ProductionOrderPage.SETRECORD(ProductionOrderHeader);
ProductionOrderPage.RUN;
END;
EXIT("PO No.");
END;

Any feedback will be appreciated!

*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 need to keep all your login in a codeunit onrun trigger and call the codeunit with each line of sales order.

    IF CODUNIT.RUN(SalesLine) THEN BEGIN

     you need to create either a table or so to store the failed saleslines here.

    END;

  • Community Member Profile Picture
    on at

    Thank you, how can I go about doing this first stage, i can't think how tackle it??

  • Verified answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Create two functions one to filter the sales line where Production BOM version is not blank which you will process and create production order and other function where Production BOM version is blank and you can pull what ever information you want from that line to the temp table or build the message to show it to the user, just use the MESSAGE box instead of Error show that it will not rollback the  process.

    Or COMMIT after your function, so that it will process the lines where production BOM version has value.

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