How to add a method in a lookup in form's field

Hi All,

Can anyone give an idea oh how to add a method to the lookup() in a forms field .

i.e usually we use lookup.addlookupfield(fieldnum(tablename, fieldname));

Now my requirement is i need to bring a method from the table to the lookup…so how should i write code???

i.e lookup.(???)

Hi,

Use lookUp.addLookupMethod(‘method1’); //here method1 is a display method on the table u lookup

Hi Lilly,

Here is one sample Look Up Method Code

void lookupItemId(FormControl control)

{

Query query = new Query();

QueryBuildDataSource queryBuildDataSource;

QueryBuildRange queryBuildRange;

SysTableLookup sysTableLookup;

;

//Create an instance of SysTableLookup with the form control passed in

sysTableLookup = SysTableLookup::newParameters(tablenum(Purchline), control);

//Add the fields to be shown in the lookup form

sysTableLookup.addLookupfield(fieldnum(Purchline,Itemid), true);

sysTableLookup.addLookupMethod(“itemName”);

//Code Added 29 - 03

//sysTableLookup.addLookupfield(fieldnum(Purchline, Linenum), false);

sysTableLookup.addLookupMethod(“IFRBRAND”); --------------------------------------> This is how i use method in a look up from the Datasource PurchLine

sysTableLookup.addLookupfield(fieldnum(Purchline, QtyOrdered), false);

//create the query datasource

queryBuildDataSource = query.addDataSource(tablenum(Purchline));

queryBuildRange = queryBuildDataSource.addRange(fieldnum(Purchline, Purchid));

queryBuildRange.value(IFRShippingPurchTable.PurchId);

//add the query to the lookup form

sysTableLookup.parmQuery(query);

// Perform lookup

sysTableLookup.performFormLookup();

}

Hi Lilly,

try below code hope it’ll helpfull 4 u

lookup.addLookupMethod(tablemethodstr(tablename,methodname)

hi Mayank k,

Thanks for your reply… Indeed i solved the issue by myself.

is there any way to add a empid(by field), name(by method) in a form’s init() method???

i tried using [tablenum(tablename, field1), tablemethodstr(tablename, methodname)], but i am getting an error… how to solve this? i need to get the display method name next to the emplid???

Hi,

What you need in your init method? look up field ? On what basis?

Thanks and Regards,

Kevin

Hi Kevin,

I am using this in SysListPanelRelationTableCallback::newForm() …