Finance and operations

Legal entity lookup with a virtual company range

Legal entity lookup with a virtual company range

I recently discovered a strange quirk with the DataArea table in AX2012.

DataArea table

The DataArea table contains the list of all legal entities. All companies that you can see in the address bar and in the status bar are saved in this table. Additionally, it contains virtual companies that can be used to share data through table collections.

The DataArea table is a system table, so you can only see and open it from the ‘System Documentation’ node in the AOT:

When you open the table you will see it has the list of legal entities, plus the virtual companies (if there are any). The virtual companies are distinguished with a checkbox ‘isVirtual’.

I wanted to create a lookup that references this table. A dialog will ask the user to select another legal entity, but in this case, the legal entity has to be another company in the system and not a virtual company.


To create this request I create a custom lookup for the dialog and then added a range for ‘isVirual’. I assumed the field is a NoYes enum field and wrote my range like this:

qbds.addRange(fieldnum(DataArea, isVirtual)).value(queryValue(NoYes::No));

It turns out that the field does not use the type NoYes, but a boolean. Instead of NoYes::No the range needed to contain the value ‘false’:

qdbs.addRange(fieldnum(DataArea, isVirtual)).value(queryValue(false));

The strange thing is that it is not possible to see this in the AOT, since the tables in the System documentation node does not have properties like other tables.


Lookup for companies (excluding virtual companies)

If you need a company lookup for a dialog, try this:

//Tina van der Vyver
public void derivedCompanyId_lookup(FormStringControl _control)
    SysTableLookup sysTableLookUp;
    QueryBuildDataSource qbds;
    Query query = new Query();

    qbds = query.addDataSource(tableNum(DataArea));

    qbds.addRange(fieldnum(DataArea, id)).value(queryNotValue(curext()));
    qbds.addRange(fieldnum(DataArea, isVirtual)).value(queryValue(false));

    sysTableLookUp = SysTableLookup::newParameters(tableNum(DataArea), _control, true);

    sysTableLookUp.addLookupfield(fieldNum(DataArea, id));
    sysTableLookUp.addLookupfield(fieldNum(DataArea, name));


And if you need a company look up for a form data source field, I have you covered:

//Tina van der Vyver
public void lookup(FormControl _formControl, str _filterStr)
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    SysTableLookup sysTableLookup;

    sysTableLookup         = SysTableLookup::newParameters(tableNum(DataArea), _formControl);
    queryBuildDataSource   = query.addDataSource(tableNum(DataArea));

    queryBuildDataSource.addRange(fieldnum(DataArea, isVirtual)).value(queryValue(false));

    sysTableLookup.addLookupField(fieldNum(DataArea, id));
    sysTableLookup.addLookupField(fieldNum(DataArea, name));


What do you think of these examples? Are they useful? Can they be improved?

Leave a Reply

Your email address will not be published. Required fields are marked *