SysFieldGroupLookup class in AX 2012–lookup from Table FieldGroups[X++]

Friends,

As we all know that we have extensively used SysTableLookup in older versions of AX to get the custom lookups. This class is still available in AX 2012.

But, in AX 2012 a new class SysFieldGroupLookup has been introduced which will help to get the lookup from the field groups of the table. This is a very useful feature as most of the fields to be added to the lookup fields can be reduced and can be pulled from the Table >> field groups directly.

Let me explain with an example.

Create a form as shown below with simple StringEdit control and set the lookup button property to “Always”

lookup

Override the lookup method of the control and add the below code

public void lookup()

{

    SysFieldGroupLookup     oSysFieldGroupLookup;

    Query                   oQuery = new Query();

 

 

    oSysFieldGroupLookup = SysFieldGroupLookup::newParameters(tablenum(CustTable), this);

    oQuery.addDataSource(tablenum(CustTable));

    oSysFieldGroupLookup.addLookupfield(fieldnum(CustTable, AccountNum));

    oSysFieldGroupLookup.parmFieldGroupNameForLookup(literalstr(‘SalesOrder’));

    oSysFieldGroupLookup.parmCloseSelectFieldId(fieldnum(CustTable, AccountNum));

    oSysFieldGroupLookup.parmQuery(oQuery);

    oSysFieldGroupLookup.performFormLookup();

}

Save the changes. Open the form by using Ctrl + O. you will find that the lookup will show the fields/columns and data of all the customers from the field Group “salesOrder” of CustTable.

lookupfields

Try with different table and field groups. Nice feature. Lookup will also display the display/data methods in the field group.

 

Try with EPCreditInfo field group. I am looking into how to get the selected value of the data method in to calling control. No luck though. I don’t see any method to return to calling control the selected data method value.

 

Happy Dax6ng,

Sreenath Reddy

Advertisements

One Response to “SysFieldGroupLookup class in AX 2012–lookup from Table FieldGroups[X++]”

  1. Bonuses Says:

    Greetings! Quick question that’s entirely off topic. Do you know how to make your site mobile friendly? My blog looks weird when browsing from my iphone4. I’m trying to find
    a theme or plugin that might be able to resolve this issue.
    If you have any suggestions, please share. With thanks!


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: