Create lookup using temporary table. Populate the temporary table with the required data from different table or if a particular values should be shown first. In the below example, the Tmpcontactperson table can populated with required data and the lookup called using the code below.
public void lookup()
{
Tmpcontactperson tmpContactPerson;
//insert record into temporary table for different criteria and perform lookup
sysTableLookup = SysTableLookup::newParameters(tableNum(Tmpcontactperson),this,false );
sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, ContactPersonId),True); sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, CustAccount),false);
sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, Name),False);
sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, Email),False);
sysTableLookup.addLookupField(fieldNum(Tmpcontactperson, Function),false);
sysTableLookup.parmTmpBuffer(tmpContactPerson);
sysTableLookup.performFormLookup();
}