Lookup method in Dynamics 365 for Finance and Operations


[DataField]
        class ModelID 
        {
            /// 
            ///
            /// 
            /// 
            /// 
            public void lookup(FormControl _formControl, str _filterStr)
            {
                //super(_formControl, _filterStr); //Table Relations

                //select * from POLModelTable
                    //where IsActive = Yes

                Query                   query = new Query();
                QueryBuildDataSource    qbdsPOLModelTable;

                qbdsPOLModelTable = query.addDataSource(tableNum(POLModelTable));
                qbdsPOLModelTable.addRange(fieldNum(POLModelTable, IsActive)).value(queryValue(NoYes::Yes));

                SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(POLModelTable), 
                _formControl);
                sysTableLookup.addLookupField(fieldNum(POLModelTable, ModelId));
                sysTableLookup.addLookupField(fieldNum(POLModelTable, ModelDescription));

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

        }

    }