How to give 3 fields in look up with filtering one with previous field in Dynamic AX 2012

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
//this select query makes the queryBuildRange values from another table for the datasource of another table
    //Assign the query to the lookup form
    // Perform lookup
    // Don’t call 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));
    qbr1 = qbds.addRange(fieldNum(HRCComp,GridId));
    qbr2 = qbds.addRange(fieldNum(HRCComp,RefPointId));


Leave a Reply

Your email address will not be published. Required fields are marked *