1 min read

Dynamics AX 2012 Enterprise Portal: range on dataSetLookup()

As described here Configuring the Lookup for a Data Set Field [AX 2012] you can change how lookup look like. What you can also do you can range to the lookup to show i.e. only rooms which are in service. Following X++ shows how to achieve this:

void dataSetLookup(SysDataSetLookup sysDataSetLookup)


List list = new List(Types::String);

Query query = new Query();

QueryBuildDataSource    queryBuildDataSource;

QueryBuildRange qbr;


// Add the table to the query.

queryBuildDataSource  = query.addDataSource(tableNum(FCMRooms));


// Specify the fields to use for the lookup.






// Supply the set of lookup fields.



// Specify the field that is returned from the lookup.



//add the range

qbr = queryBuildDataSource.addRange( fieldnum(FCMRooms, InService));


//if we don’t want user to be able to change range we need to lock it



// Pass the query to the SysDataSetLookup so that the query is used.



We need to lock the range in order user is unable to change the range. Otherwise if user in search will specify RoomName “Cubicle 8” (when inService == No) it will still appear because the range will be simply overwritten.