Saturday, October 31, 2015

AX 2012:Loop through records

Loop through record from data source [AX 2012]

1.Using a while loop

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

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

2.Using a for loop

salesLine_ds = _salesLine.dataSource();
    for (localSalesLine = salesLine_ds.getFirst(true) ? salesLine_ds.getFirst(true) :    salesLine_ds.cursor();
         localSalesLine;
         localSalesLine = salesLine_ds.getNext())
    {      
        //your logic
    }

No comments:

Post a Comment

Table browser URL in D365FO

Critical Thinking icon icon by Icons8