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)

Clearing Globals

(0) ShareShare
ReportReport
Posted on by

I'm trying to do something simple which I always find myself having trouble with. I've created a global variable which I want to assign the Value of "Qty to ship" to it. This is used when opening a page. However it currently is just showing 1 and is repeating this value for all lines.  Where do i need to position my CLEAR? 

Here is the code.

 


recCustomer.GET(recSalesLine."Sell-to Customer No.");
Rec := recSalesLine;
CLEAR(gintQtyonPick);
gintQtyonPick := "Qty. to Ship"; // HERE IS THE VALUE I NEED TO ASSIGN
IF IndentTrue THEN BEGIN
Indentation := 0;
"Line No." := 0;
"No." := "Sell-to Customer No.";
Description := recCustomer.Name;
CLEAR("Qty. to Ship");
CLEAR(Quantity);
CLEAR("Promised Delivery Date");
CLEAR("Outstanding Quantity");
END ELSE BEGIN
Indentation := 1;
END;
INSERT(FALSE);

*This post is locked for comments

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

    These should Match 109.PNG

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    If you are doing this under Repeat Until then you need to clear this right away inside Repeat.

  • Community Member Profile Picture
    on at

    This is what it currently looks like after your sugegstion, it's still producing just 1.

    DELETEALL;

    recSalesLine.RESET;

    recSalesLine.SETRANGE("Document Type", recSalesLine."Document Type"::Order);

    recSalesLine.SETRANGE(Type, Type::Item);

    recSalesLine.SETFILTER("Outstanding Qty. (Base)", '<>%1', 0);

    IF recSalesLine.FINDSET(FALSE, FALSE) THEN REPEAT

     CLEAR(gintQtyonPick);

     CLEAR(IndentTrue);

     IF recSalesLine."Document No." <> recSalesLineTMP."Document No." THEN BEGIN

       IndentTrue := TRUE;

       AssignSalesValues(IndentTrue, recSalesLine);

        AssignSalesValues(FALSE, recSalesLine);

     END ELSE BEGIN

       AssignSalesValues(IndentTrue, recSalesLine);

     END;

     recSalesLineTMP := recSalesLine;

    UNTIL recSalesLine.NEXT =0;

    FINDFIRST;

    AssignSalesValues(IndentTrue : Boolean;recSalesLine : Record "Sales Line")

    recCustomer.GET(recSalesLine."Sell-to Customer No.");

    Rec := recSalesLine;

    IF IndentTrue THEN BEGIN

     Indentation := 0;

     "Line No." := 0;

     "No." := "Sell-to Customer No.";

     Description := recCustomer.Name;

     CLEAR("Qty. to Ship");

     CLEAR(Quantity);

     CLEAR("Promised Delivery Date");

     CLEAR("Outstanding Quantity");

    END ELSE BEGIN

     Indentation := 1;

     gintQtyonPick := "Qty. to Ship";

    END;

    INSERT(FALSE);

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    You are not assigning the value under repeat until you are doing this in the next set of codes.

    Why You have written FINDFIRST after UNTIL recSalesLine.NEXT =0;.

    There are many questions coming in my mind after going through your code.

    Clear the global variables after FINDFIRST and then try.

  • Community Member Profile Picture
    on at

    THE FINDFIRST is simply to ensure the page is loaded at the top instead of showing the bottom of the page when opened.

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    Anyways did it solved your case??

  • Community Member Profile Picture
    on at

    No the column is just completely blank now on all lines :)

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

    I believe there's some tuning of codes needed. I will suggest to debug ones and cross verify what exactly and where it is playing with that global variable OR there's some else case that needs to be figured out.  

  • Verified answer
    Community Member Profile Picture
    on at

    Issue has been resolved! Thanks for your help

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