Filtering Data to appear in Lookup

Hi All,
I’m trying to filter data to appear in lookup, so I have used a query and add the range that I need,
the problem is I need another data to appear in the lookup in some cases,

I have used simple SQL statement

while select * from dAPLoanType1 notExists join dAPGradesLoanTypes
where dAPLoanType1.LoanTypeId == dAPGradesLoanTypes.LoanTypeId

The Question is how I can add the Values from dAPLoanType1.LoanTypeId to appear in the lookup besides the value that appear by the Query ?

This is My code :

public void lookup(FormControl _formControl, str filterStr)
{

// Define Lookup

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(DAPEmployeeGradesLoanTypes), _formControl);

// Declaration

Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
DAPEmployeeGrade dAPEmployeeGrade;
DAPEmployeeGradesLoanTypes dAPGradesLoanTypes;
DAPLoanType dAPLoanType1;

// The Value of the Employee Grade of selected Worker

DAPEmployeeGrade empGrade = DAPEmplContract::findActiveContractForEmpl(DAPEmplLoans.Worker).EmployeeGrade;
;

queryBuildDataSource = query.addDataSource(tablenum(DAPEmployeeGradesLoanTypes));

while select forUpdate * from dAPLoanType1 notExists join dAPGradesLoanTypes
where dAPLoanType1.LoanTypeId == dAPGradesLoanTypes.LoanTypeId

// The Field names that will Appear in the Lookup

sysTableLookup.addLookupfield(fieldNum(DAPEmployeeGradesLoanTypes,LoanTypeId));
sysTableLookup.addLookupfield(fieldNum(DAPEmployeeGradesLoanTypes,EmployeeGrade));

// Limit the Appearance of the Data according to the Range

queryBuildDataSource.addRange(fieldNum(DAPEmployeeGradesLoanTypes, EmployeeGrade)).value(queryValue(empGrade));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}

Hi

Please add the code instead of select statement

queryBuildDataSource = query.addDataSource(tablenum(DAPEmployeeGradesLoanTypes));

querybuilddatasource1 = queryBuildDatasource.adddatasource(tablenum(dAPGradesLoantype));

querybuildDatasource1.relations(true);

querybuilddatasource1.joinMode(JoinMode::NoExistsJoin);

I hope that it’ll help you

Don’t forget to verify solution if solve your issue

Regards

Syed Abuthahir