blog for Dynamics Axapta

Create LookUps Using X++

Hi All,

Here I create Lookups using X++ Code(without Ax Table or EDT relation). For that i override a String(Text) Control’ s lookup method.

public void lookup()

{
//super();

// Added by Vasanth Arivali

// Declaration
Query   LookupQuery    =   new Query();

QueryBuildDataSource     LookupQueryBuildDataSource;

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

;

// Add fields that you want in Lookups

CustomSysTableLookup.addLookupField(fieldNum(InventTable, ItemId));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemName));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemGroupId));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,NameAlias));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemType));

CustomSysTableLookup.addLookupField(fieldNum(InventTable,DimGroupId));

// Add DataSource, Range and Value

LookupQueryBuildDataSource =

LookupQuery.addDataSource(tableNum(InventTable));

LookupQueryBuildRange=

LookupQueryBuildDataSource.addRange(fieldNum(InventTable,ItemVisibility));

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

// Execute the Query

CustomSysTableLookup.parmQuery(LookupQuery);

CustomSysTableLookup.performFormLookup();
// Added by Vasanth Arivali

}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: