1. Create 3 fields for the table “FormTable” and add to form datasource.
2. First field with relation in table level so automatically you will get the look up.
· As FormTable.Fild1
3. Second field with following lookup code, this look up filter with previous field.
· As FormTable.Fild2
Public void lookup ()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
QueryBuildRange queryBuildRange1;
SysTableLookup sysTableLookup;
HRCCompGrid HRCCompGrid;
;
//Create an instance of SysTableLookup with the form control passed in
sysTableLookup = SysTableLookup::newParameters(tablenum(HRCCompRefPointSetupLine), this);
//Add the fields to be shown in the lookup form
sysTableLookup.addLookupfield(fieldnum(HRCCompRefPointSetupLine, RefPointId));
sysTableLookup.addLookupfield(fieldnum(HRCCompRefPointSetupLine, RefPointSetupId));
//create the query datasource
queryBuildDataSource = query.addDataSource(tablenum(HRCCompRefPointSetupLine));
//Only show LocalEndpoints for the current company
queryBuildRange = queryBuildDataSource.addRange(fieldnum(HRCCompRefPointSetupLine, RefPointSetupId));
selectHRCCompGrid where HRCCompGrid.GridId ==SalaryAmend.GridId ;
//SalaryAmend.GridId is the FormTable.Fild1
queryBuildRange.value(HRCCompGrid.RefPointSetupId);
//this select query makes the queryBuildRange values from another table for the datasource of another table
//Assign the query to the lookup form
sysTableLookup.parmQuery(query);
// Perform lookup
sysTableLookup.performFormLookup();
// Don’t call super()
//super()
}
4. Third field given a lookup with filtering on based of above 2 fields.
· As FormTable.Fild3
public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource,qbds;
QueryBuildRange qbr1,qbr2;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(HcmCompensationLevel), this);
sysTableLookup.addLookupfield(fieldnum(HcmCompensationLevel, CompensationLevelId));
sysTableLookup.addLookupfield(fieldnum(HRCComp, RefPointId));
sysTableLookup.addLookupfield(fieldnum(HRCComp, GridId));
queryBuildDataSource = query.addDataSource(tableNum(HcmCompensationLevel));
qbds = queryBuildDataSource.addDataSource(tableNum(HRCComp));
qbds.joinMode(JoinMode::ExistsJoin);
qbds.relations(true);
qbr1 = qbds.addRange(fieldNum(HRCComp,GridId));
qbr2 = qbds.addRange(fieldNum(HRCComp,RefPointId));
qbr1.value(SalaryAmend.GridId);
qbr2.value(SalaryAmend.RefPointId);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
//super();HcmCompensationLevel
}