1. For Normal field
a. Inside DS-Path – Form < DataSource < table < Field < method - Lookup
public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource qbdsVendInvoiceInfoTable;
// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup =
sysTableLookup::newParameters(tableNum(VendTable), _formControl);
// Create the query.
qbdsVendTable =
query.addDataSource(TableNum(VendTable));
// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);
// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(VendTable, AccountNum));
sysTableLookup.addLookupfield(fieldNum(VendTable, Party));
// Perform the lookup
sysTableLookup.performFormLookup();
}
b. Inside Design
Path- Form<Design < Field< method – Lookup()
public void lookup()
{
SysTableLookup relationsLookup;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
Query query = new Query();
relationsLookup = SysTableLookup::newParameters(tableNum(DirRelationshipTypeTable), this, true);
relationsLookup.addLookupfield(fieldNum(DirRelationshipTypeTable , RelationshipTypeId));
relationsLookup.addLookupfield(fieldNum(DirRelationshipTypeTable , Description));
relationsLookup.addLookupfield(fieldNum(DirRelationshipTypeTable , ChildPartyType));
relationsLookup.addLookupfield(fieldNum(DirRelationshipTypeTable , ParentPartyType));
relationsLookup.addLookupfield(fieldNum(DirRelationshipTypeTable , ChildParentName));
relationsLookup.addLookupfield(fieldNum(DirRelationshipTypeTable , ParentChildName));
qbd = query.addDataSource(tableNum(DirRelationshipTypeTable));
qbr = qbd.addRange(fieldNum(DirRelationshipTypeTable, ChildPartyType));
qbr.value(queryValue(DirPartyType::Person));
qbr = qbd.addRange(fieldNum(DirRelationshipTypeTable, ParentPartyType));
qbr.value(queryValue(DirPartyType::Person));
relationsLookup.parmQuery(query);
relationsLookup.performFormLookup();
}
2. For reference field
Path- Form < DS < table < field < lookupReference()
public Common lookupReference(FormReferenceControl _formReferenceControl)
{
Query query = new Query();
QueryBuildDataSource qbrdDirPartytable, qbdsDirPartyOrganization;
SysReferenceTableLookup sysTableLookup =
SysReferenceTableLookup::newParameters(tableNum(DirPartyTable), _formReferenceControl, true);
;
qbrdDirPartytable = query.addDataSource(tableNum(DirPartyTable));
qbdsDirpartyorganization =
qbrdDirPartytable.addDataSource(tableNum(DirOrganization));
qbdsDirpartyorganization.joinMode(JoinMode::ExistsJoin);
qbdsDirpartyorganization.relations(true);
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupField(fieldNum(DirPartyTable, name));
sysTableLookup.addLookupField(fieldNum(DirPartyTable, PartyNumber));
sysTableLookup.addLookupField(fieldNum(DirPartyTable, NameAlias));
sysTableLookup.addLookupField(fieldNum(DirPartyTable, DEL_Type));
return sysTableLookup.performFormLookup();
}