Thursday, July 21, 2011

Focus a particular lookup record in LookUpform

Hi,

Focus on the particular record in the opened lookup.

args.lookupRecord(reasonTable::find(this.text()));

Thanks,
/Ashlesh

Tuesday, July 19, 2011

Open a form in AX Workspacewindow only

Hi,
Using below lines before super() call in init() of the form, the form will open in AX Workspacewindow only.

if(this.form().design().windowType()==FormWindowType::Standard)
this.form().design().windowType(FormWindowType::Workspace);

Thanks.

Tuesday, July 5, 2011

Filtering different file types in a browse dialog

Hi,

to filter the different types of files in a browse dialog,

public Object dialog()
{
    DialogRunbase       dialog = super();
    #AviFiles
    #Excel

    dialogFilename = dialog.addField(typeId(FilenameOpen));
    dialog.filenameLookupFilter(["@SYS28576",#XLSX,"@SYS100852","*.csv"]);
    dialog.filenameLookupTitle("Upload from EXCEL/CSV");
    dialogFilename.value(filename);
    return dialog;
}

To build a LIKE query in AX 2009

Hi,

to build a QueryRun object same as LIKE SQL query.

void createQuery()
{
    Query query = new Query();
    QueryRun queryRun;
    BOMTable bt;
    InventTable it;
    BOMId bomId;
    ;
    it = InventTable::find('ELB002');
    query.addDataSource(tableNum(BOMTable)).addRange(fieldNum(BOMTable, BOMId)).value(strfmt("%1-*",it.ItemId));
    queryRun = new QueryRun(query);
   
    bomId = strfmt("%1-%2",it.ItemId, SysQuery::countTotal(queryRun)+1);
    info(bomId);
}

Also review for more details QueryRanges

Hope it helps.

Thanks,
/Ashlesh

To find MAX, MIN, COUNT of any table in AX 2009

Hi,
Below is the code snipet to find out the MAX value of a particular field in a particular table.
static void MaxValueTest(Args _args)
{
    str maxValue(TableId tableId, FieldId fieldId)
    {
        QueryRun qr = new QueryRun(new Query());
        qr.query().addDataSource(tableId).addSelectionField(fieldId, SelectionField::Max);
        return qr.next() ? any2str(qr.get(tableId).(fieldId)) : '';
    }
    ;
    info(maxValue(tableNum(BOMTable), fieldNum(BOMTable,BOMId)));
}

In the above example the "SlecttionField" has the mulitple static filed which can give you more choices.

Thanks,
/Ashlesh