Hi Dude,
Today Let us see how we will filter data in Reference group .
Most of the time there comes a situation, where one wants to display
customized (filtered) data in reference groups.so here is a piece of
code that satisfy your exact needs.You can filter the data according to
your needs and displays it to the user.
In the example code below, i have used two tables, Student &
Department.There is a foreign key relationship between Student and
Department tables.Here a Department is associated to one or more
Students. The Structure of the tables is shown in the figure below.
A ReferenceGroup control named "Department" is added on a form which
contains all the values that are in Department table as shown in the
figure below.
Now if we want to display(filter) only those Departments whose
Dept(enum) value is Computer Science, in short we want to display only
Computer Science departments like the one in the figure below.
For the above behavior of the ReferenceGroup, simply override the
lookupReference() method of the
Department field of the
Student datasource and place the following code there.
Code Snippet.
Common ret;
SysReferenceTableLookup sysReferenceTableLookup;
QueryBuildDataSource queryBuildDataSource;
Query query = new Query();
sysReferenceTableLookup =
SysReferenceTableLookup::newParameters(tableNum(Department),_formReferenceControl, true);
queryBuildDataSource = query.addDataSource(tableNum(Department));
queryBuildDataSource.addRange(fieldNum(Department, Dept)).value(SysQuery::value(Dept::ComputerScience));
sysReferenceTableLookup.addLookupfield(fieldNum(Department, Name));
sysReferenceTableLookup.addLookupfield(fieldNum(Department, Dept));
sysReferenceTableLookup.addLookupfield(fieldNum(Department, ID));
sysReferenceTableLookup.parmQuery(query);
ret = sysReferenceTableLookup.performFormLookup();
return ret;
Happy Coding :)