Monday 9 January 2012

Create LookUp using X++ in Ax 2009

Hi Friends,

 Today we are going to create look up using code
1. Create a Form
2.Add a string Edit Control
3.In the methods of control write the following code

public void lookup()

{
//super();


// Declaration
Query   LookupQuery    =   new Query();

QueryBuildDataSource     LookupQueryBuildDataSource;

QueryBuildRange                  LookupQueryBuildRange;
SysTableLookup CustomSysTableLookup =       SysTableLookup::newParameters(tableNum(CustTable), this);

;

// Add fields that you want in Lookups

CustomSysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));

CustomSysTableLookup.addLookupField(fieldNum(CustTable,Name));

LookupQueryBuildDataSource =

LookupQuery.addDataSource(tableNum(CustTable));

LookupQueryBuildRange=

LookupQueryBuildDataSource.addRange(fieldNum(CustTable,AccountNum));

//LookupQueryBuildRange.value(queryValue(NOYESCOMBO::Yes));

// Execute the Query

CustomSysTableLookup.parmQuery(LookupQuery);

CustomSysTableLookup.performFormLookup();

}
Vivek Chirumammila

2 comments:

  1. Hi,

    How to add more than one filter conditon from this above query?

    i.e., i need to further filter the account numbers having currencies as INR..

    Thanks

    ReplyDelete
  2. How should we make the first element to be displayed in the combo box through code ...

    ReplyDelete