Thursday, 18 February 2016

List of items that have been sold on a sales order id Using Code in Ax 2012

class SalesListItems
{
    QueryRun queryRun;
}

Methods
static void main(Args _args)
{
    SalesListItems salesListItems = new SalesListItems();
    salesListItems.run();

}

private void run()
{
    this.buildQuery();
    if (queryRun.prompt())
    this.listItems();
}

private void listItems()
{
    SalesLine salesLine;
    while (queryRun.next())
    {
        salesLine = queryRun.get(tableNum(SalesLine));
        info(strFmt("%1 %2",salesLine.ItemId,salesLine.itemName()));
    }
}

private void buildQuery()
{
    Query query;
    QueryBuildDataSource dataSource;
    query = new query();

    dataSource = query.addDataSource(tableNum(SalesLine));
    query.addQueryFilter(dataSource, fieldStr(SalesLine,SalesId));
    queryRun = new QueryRun(query);
}




No comments:

Post a Comment