Monday 14 December 2015

how to bind Lookup in ax 2012.

Bind lookup in AX 2012


Description:-

In this example we explain that how to add control with Lookup in AX 2012. Or how to bind Lookup for string edit control in ax 2012.

Look up is nothing but a one kind of terms and are used in ax to show data of other table in dropdown list format.

To create lookup  for any field just override the Lookup  method of the field in which you want to create lookup and paste the below code in your lookup method and change the table name and field name from the below code as per your requirements.

But the main disadvantages of using lookup is you need to override this method on every form in which you required.so if you need same functionality on all the places accessing the field on the form. You have to use EDT relation ship for this.check this post for EDT in AX Create EDT instead of Lookup in AX 2012



Code:- 

public void lookup()
{

     Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;

    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(kiritCityMaster), this);
    queryBuildDataSource = query.addDataSource(tableNum(kiritCityMaster));
    sysTableLookup.addLookupField(fieldNum(kiritCityMaster, CityCode));
    sysTableLookup.addLookupField(fieldNum(kiritCityMaster, CityName));
    sysTableLookup.addLookupField(fieldNum(kiritCityMaster, Statecode));
    sysTableLookup.addLookupMethod(tableMethodStr(kiritCityMaster,GetStateName ));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();



}


This entry was posted in :

0 comments:

Post a Comment