AX – D365FO – Loop through record from data source



///////////////////////////////////////////////
Using a while loop

SalesLine localSalesLine;
localSalesLine  = salesLine_ds.getFirst(true) as SalesLine;

if (localSalesLine)
{
    while (localSalesLine)
    {
        //Do your thing
         localSalesLine = salesLine_ds.getNext() as SalesLine;
    }
}

///////////////////////////////////////////////
Using a for loop

SalesLine localSalesLine;

for (localSalesLine = salesLine_ds.getFirst(true) ? salesLine_ds.getFirst(true) : salesLine_ds.cursor();
     localSalesLine;
     localSalesLine = salesLine_ds.getNext())
{       
     //Do your thing
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s