Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

x++ while select "next" record

Posted on by Microsoft Employee

Hi all,

Have some pseudo code:

SalesTable s;

SalesLine sl;

;

while select s where s.someconditions...

{

//do some stuff 1

sl = SalesLine::find(......);

if(sl.someFunctionThatReturnsAnInt < 300)

{

next s;

}

//do some stuff 2

}

 

-----------------------------

Question.  The keyword "next" simply moves to the next record and continues down to "do some stuff 2?"

What I want is to recognize that my Int function is < 300 and then jump to the next record in the while select statement but I want it to jump to "do some stuff 1" instead of "do some stuff 2."

So basically how do you jump to the next record in SalesTable and continue at the top of the while select statement and bypass "do some stuff 2"

What I believe is happening now is that using "next" fetches the next s record but continues on to "do some stuff 2" which is not my desired results.  I want to not continue on and start my with the next record at the top of the while select ("do some stuff 1")

Any ideas?

Thanks in advance!

----------

Edit:  It seems like the "next" call isn't moving to the next record in SalesTable at all...  Just pointing this out.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: x++ while select "next" record

    Thank you Joris.  Continue is the keyword I was looking for.

  • Verified answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    Re: x++ while select "next" record

    in a while select the keyword "next" has no meaning. you either do:

     

    while select salesTable

    {

        do something;

     

        if (you need to skip)

            continue;

     

        do something else;

    }

     

    you use next like this:

     

    select salesTable;

    while(salesTable.RecId != 0)

    {

        do something;

     

        if (you need to skip)

        {

            next salesTable;

            continue;

        }

     

        do something else;

     

        next salesTable;

    }

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans