Monday, December 26, 2011

How to create a dialog box in a report

public class ReportRun extends ObjectRun
{
    ItemGroupId itemGroup;
    DialogField dialogItemGroup;
}
public Object dialog(Object _dialog)
{
    DialogRunBase dialog;
    ;
    dialog = super(_dialog);
    dialog.caption("Inventory");
    dialog.addGroup("Item Group");
    dialogItemGroup = dialog.addFieldValue(typeid(ItemGroupId),itemGroup,"Item Group");
    return dialog;
}
public boolean getFromDialog()
{
    ;
    itemGroup   = dialogItemGroup.value();
    return true;
}
public boolean fetch()
{
    Query                   q;
    QueryRun                qr;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    ;
    q       = new Query(this);
    qbds    = q.dataSourceTable(tablenum(InventTable));
    qbr     = qbds.addRange(fieldnum(InventTable,ItemGroupId));
    qbr.value(itemgroup);
    qr      = new QueryRun(q);
    while( qr.next() )
    {
        inventTable = qr.get(tablenum(InventTable));
        this.send(inventTable);
    }
    return true;
}

Note: for reference you can check LedgerCheckTrans report

Friday, December 23, 2011

AX in Hindi

Guys this is what AX is in hindi, after running the hindi script in microsoft. I found it funny so sharing with you guys.

Check for empty values inside a query

Suppose we need to check/filter data inside the tabel on the basis of null values, or we need to fetch the data from a table where the value of the field is null.

sysQuery::valueEmptyString for the select query to fetch the data from the table where there is no value for the selected record.

sysQuery::valueNotEmptyString for filtering data where there is value in the field, this will fetch only those records for which there is value.

For example, we can use this inside filter query on datasources of the form, inside the init or execute query methods.

QueryBuildRange        QueryBuildRange;
;
QueryBuildRange = this.query().dataSourceTable(tablenum(CustTable)).
           addRange(fieldnum(CustTable, AccountNum));
QueryBuildRange.value(sysQuery::valueNotEmptyString());

This will only display non empty records on the form grid.

Reference: http://msdn.microsoft.com/en-us/library/aa866017(v=ax.50).aspx