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

  • Verified answer
    Suresh Kulla Profile Picture
    47,688 on at
    RE: Creating a Prod. Order

    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.

  • Community Member Profile Picture
    on at
    RE: Creating a Prod. Order

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

  • Suggested answer
    Mohana Yadav Profile Picture
    60,228 Super User 2025 Season 1 on at
    RE: Creating a Prod. Order

    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;

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans