it is common for user to search item based on name. but currently on AX 2012, onHand form can’t provide search based on item name or search name. It will take a little modification from technical side.
example how to do it :
1. you can join directly on form datasource or create view like example (i’m using the view that already created for another purpose)
2. on InventSumTable add relations like this.
3. then go to form onHand (InventOnHandItem), and add the view to datasource
4. open class InventDimCtrl_Frm_OnHand and modify method modifyQuery , on class declaration parameter, add new parameter FormDataSource with default null parameter. then define new variable QueryBuildDataSource.
5. on the last line of the method modifyQuery , add code like example :
if(_tidInventLookUp) { qbsInventLookup = query.dataSourceName(_tidInventLookUp.name()); //filter current company language qbr = SysQuery::findOrCreateRange(qbsInventLookup, fieldnum(TIDInventLookup, LanguageId)); qbr.value(queryValue(CompanyInfo::languageId())); qbsInventLookup.addGroupByField(fieldNum(TIDInventLookup,Name)); qbsInventLookup.addGroupByField(fieldNum(TIDInventLookup,NameAlias)); }
5. then back to the form, on datasource inventSUm, on executeQuery , modify the code from
void executeQuery() { element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS); super(); }
to
void executeQuery() { element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS,TIDInventLookUp_ds); super(); }
6. drag the field from newly add datasource on form to the grid :
7. Voila done, example result, :
note: remember to GROUPBY on code if you add new field to the form, or the field on form will show “UNRETRIEVED”
Great help. Many Thanks…
It is very useful and helpful.
Thanks a lot.
Thank you so much. This post is really useful.
I have a problem at AX 2009. It works properly when you filtered a item name but if you clear filter by button, I get an error ([Microsoft][SQL Native Client][SQL Server]A column has been specified more than once in the order by list. Columns in the order by list must be unique.)
if(inventTable_DS) // DRT MK madde adında arama)
{
qbsInventTable = inventSum_DS.query().dataSourceName(inventTable_DS.name());
qbsInventTable.sortClear(); // this solved the error
qbsInventTable.addGroupByField(fieldNum(InventTable, ItemName));
}