web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Production Order

(0) ShareShare
ReportReport
Posted on by

Hi I have this code on the OnValidate Function. With the Set ranges at the start once I find the production order, when i try to find the prod order component, using the recprodorder."No." it's coming up blank in the debugger. How can I ammend this to find the right production order component? 

//FIND production Order
recProdOrder.RESET;
recProdOrder.SETRANGE("No.", "Source No.");
recProdOrder.SETRANGE("Item No.", "Item No.");

// Find Production Order Component for Production order
recProdOrderComponent.RESET;
recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No.");//This isn't finding anything
// Check If Items found are Customer Specific
IF recProdOrderComponent.FINDFIRST THEN BEGIN
recProdOrderComponent.CALCFIELDS(FixedVariant);
IF recProdOrderComponent.FixedVariant THEN
ItemVariant.GET("Item No.","Variant Code");
//Check if variant is customer specific, and if it matches prod Order No.
IF ItemVariant.CALCFIELDS("Customer Specific") THEN
//Find the Production Order
recProdOrder.SETRANGE("No.", recProdOrderComponent."Prod. Order No.");
IF recProdOrder."Customer No." <> ItemVariant.Manufacturer THEN
ERROR(Text024);
END;

*This post is locked for comments

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

    This is written on the Warehouse Activity Line table

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    recProdOrder.RESET;
    recProdOrder.SETRANGE("No.", "Source No.");
    recProdOrder.SETRANGE("Item No.", "Item No.");
    If recProdOrder.FINDFIRST THEN --->  You forgot this line 
    // Find Production Order Component for Production order
    recProdOrderComponent.RESET;
    recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No.");//This isn't finding anything
    // Check If Items found are Customer Specific
    IF recProdOrderComponent.FINDFIRST THEN BEGIN
    recProdOrderComponent.CALCFIELDS(FixedVariant);
    IF recProdOrderComponent.FixedVariant THEN
    ItemVariant.GET("Item No.","Variant Code"); 
    //Check if variant is customer specific, and if it matches prod Order No.
    IF ItemVariant.CALCFIELDS("Customer Specific") THEN
    //Find the Production Order
    recProdOrder.SETRANGE("No.", recProdOrderComponent."Prod. Order No.");
    IF recProdOrder."Customer No." <> ItemVariant.Manufacturer THEN
    ERROR(Text024);
    END;

  • Community Member Profile Picture
    on at

    Thank you, my confusion is.. How can I get this SETRANGE to work properly essentially.

    97.PNG

  • Suggested answer
    Suresh Kulla Profile Picture
    50,278 Super User 2026 Season 1 on at

    Put the breakpoint on that line, only when the breakpoint is hit, i.e. when the cursor is inside the loop that value will be shown to you in the debugger. If you are trying to lookup the value before the execution of the loop you will see the blank value.

  • Community Member Profile Picture
    on at

    Thanks, I've tried this but it's still not pickinh up any value for the

    recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No."); line

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    Hi

    You need to write the code in block using begin end

    As well as activate debugger and check

  • Verified answer
    Suresh Kulla Profile Picture
    50,278 Super User 2026 Season 1 on at

    Replace your code with this

    recProdOrder.RESET;

    recProdOrder.SETRANGE("No.", "Source No.");

    recProdOrder.SETRANGE("Item No.", "Item No.");

    IF recProdOrder.FINDFIRST THEN BEGIN

      // Find Production Order Component for Production order

      recProdOrderComponent.RESET;

      recProdOrderComponent.SETRANGE("Prod. Order No.",recProdOrder."No.");//This isn't finding anything

      // Check If Items found are Customer Specific

      IF recProdOrderComponent.FINDFIRST THEN BEGIN

        recProdOrderComponent.CALCFIELDS(FixedVariant);

        IF recProdOrderComponent.FixedVariant THEN BEGIN

          ItemVariant.GET("Item No.","Variant Code");

        //Check if variant is customer specific, and if it matches prod Order No.

          IF ItemVariant.CALCFIELDS("Customer Specific") THEN BEGIN

        //Find the Production Order

          IF recProdOrder."Customer No." <> ItemVariant.Manufacturer THEN

            ERROR(Text024);

         END;

       END;

     END;

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans