Lookup from multiple tables

Hi

pastedimage1551165120129v1.png

I have the following fields from two tables, I need to filter the second field based on the selected value from the first field.

I have created a lookup method on the datasource under the second field,am aware aware that I must filter based on the first field selection.

this is my code and its not filtering,how do i resolve this.

public Common lookupReference(FormReferenceControl _formReferenceControl)
{
    HcmRatingLevel               ret;
    SysReferenceTableLookup      sysReferenceTableLookup;
    QueryBuildDataSource         queryBuildDataSource,queryBuildDataSourceRating;
    QueryBuildRange              qbr;
    Query                        query = new Query();

    sysReferenceTableLookup =
    SysReferenceTableLookup::newParameters(tableNum(HcmRatingLevel),_formReferenceControl, true);
    queryBuildDataSource = query.addDataSource(tableNum(HcmRatingLevel));
    queryBuildDataSourceRating = queryBuildDataSource.addDataSource(tableNum(HcmRatingModel));
    queryBuildDataSourceRating.relations(true);
    queryBuildDataSourceRating.joinMode(JoinMode::InnerJoin);
    qbr = queryBuildDataSourceRating.addRange(fieldNum(HcmRatingModel,RatingModelId));
   

    sysReferenceTableLookup.addLookupfield(fieldNum(HcmRatingLevel, RatingLevelId));
    sysReferenceTableLookup.addLookupfield(fieldNum(HcmRatingLevel, Description));
    sysReferenceTableLookup.addLookupfield(fieldNum(HcmRatingLevel, Factor));
    sysReferenceTableLookup.parmQuery(query);

    ret = sysReferenceTableLookup.performFormLookup();
    return ret;
}

You’ve created a range for RatingModelId, but you haven’t set any value, therefore it doesn’t have any effect.

Thanks for the response.

below is my code for setting the value, it does not display any data.

qbr.value(SysQuery::value(HcmRatingModelRecId));