how to add lookup fields in form

I am creating one form with two tables how should i get look up for those tables fields

like if a i select mondal ,i want all related Panchayat Details(with that mandal Only)

Hello Ramesh,

Create relation on EDT of that field with the related table. if you have some specific requirment you have to create lookup method ,it creates lookup on filed dyanmically .

Share some detail that i can understand what u really want do .

hi,

try like this…

first of all create an EDT for mandal to fetch the data entered in main table to secondary table…

and give that EDT to mandal fields in both the tables…

now in order to get the Panchayat Details based on the mandal…

write this code in the Panchayat Details datasource lookup method…

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource queryDataSourceCode;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;
primarytable primarytable ;
;

sysTableLookup=SysTableLookup::newParameters(tableNum(primarytable ),_formControl);
sysTableLookup.addLookupField(fieldNum(primarytable , mandal ));
sysTableLookup.addLookupField(fieldNum(primarytable , Panchayat Details));
queryDataSourceCode = query.addDataSource(tableNum(primarytable ));
queryDataSourceCode.addRange(fieldNum(primarytable , mandal )).value(secondary table.mandal );
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

k…,

in my table i have Four fields like" MandalName,PanchayatName,VillageName,Habitation Name"

so if i Select Mondal the and Panchayat in Particular Form record’s related to the Mondal should look up

sorry …

where i can place this code means in form level or Table level

please explain

i put this code in Form level Datasource it cont’ show error con’t perform Perpectly

what is Primary Table, what is Secondary table and

as well as PanchayatDetails-Means

hi,

panchayat details means the field related to mandal u specified…

write the code in form datasource field level lookup method…

it will work or else share ur code…

i wrote this code in Direct Table Methods

public client static void lookupByMandalWise(FormStringControl ctrl, mandalName mandalName)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(Prx_GramPanchayatTable), ctrl);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
;

sysTableLookup.addLookupfield(fieldnum(Prx_GramPanchayatTable,GramPanchayatName));

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

if (MandalName)
queryBuildDataSource.addRange(fieldnum(Prx_GramPanchayatTable, MandalName)).value(queryValue(MandalName));

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

///////////////////////////////////////////////////////////////////////////////////////and ,I wrote this code in Form Level Datasource field Methods

public void lookup(FormControl _formControl, str _filterStr)
{
if (exmp.MandalName)
{
Prx_GrampanchayatTable::lookupByMandalWise(_formControl, exmp.MandalName);
}
else
{
super(_formControl, _filterStr);
}
}

but it con’t work this is my source code

hi,

i think the code is perfect what is the problem u r facing with the current code…

in these no errors but cont’ perform properly

means if i select mondalname it will show not only that Mandal releted panchayats but also

show all panchayat lists…

so What’s Problem ,if any other Method is there for this

hi,

For example u are having 2 fields in Mandal Table named mandal , Panchayat…

Now create an EDT for Mandal …

After entering the required data into these fields …

Create the 2 fields in the table where u want to see these mandals in a dropdown and

give the EDT Created earlier…

Lets take the custtable where we require these fields…

Create the 2 fields in the table where u want to see these mandals in a dropdown and

give the EDT Created earlier…

Now u wil get the mandals specified in the mandal table in a dropdown…

to get the related panchayats in the panchayat field in custtable

Just write a lookup method in custtable datasource Panchayat field in the below format…

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource queryDataSourceCode;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;
Mandaltable Mandaltable ;
;

sysTableLookup=SysTableLookup::newParameters(tableNum(Mandaltable ),_formControl);
sysTableLookup.addLookupField(fieldNum(Mandaltable , mandal ));
sysTableLookup.addLookupField(fieldNum(Mandaltable , Panchayat ));
queryDataSourceCode = query.addDataSource(tableNum(Mandaltable ));
queryDataSourceCode.addRange(fieldNum(Mandaltable , mandal )).value(custtable.mandal );
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

hi,

For example u are having 2 fields in Mandal Table named mandal , Panchayat…

Now create an EDT for Mandal …

After entering the required data into these fields …

Create the 2 fields in the table where u want to see these mandals in a dropdown and

give the EDT Created earlier…

Lets take the custtable where we require these fields…

Create the 2 fields in the table where u want to see these mandals in a dropdown and

give the EDT Created earlier…

Now u wil get the mandals specified in the mandal table in a dropdown…

to get the related panchayats in the panchayat field in custtable

Just write a lookup method in custtable datasource Panchayat field in the below format…

public void lookup(FormControl _formControl, str _filterStr)
{
Query query = new Query();
QueryBuildDataSource queryDataSourceCode;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;
mandaltable mandaltable ;
;

sysTableLookup=SysTableLookup::newParameters(tableNum(mandaltable ),_formControl);
sysTableLookup.addLookupField(fieldNum(mandaltable , mandal ));
sysTableLookup.addLookupField(fieldNum(mandaltable , Panchayat));
queryDataSourceCode = query.addDataSource(tableNum(mandaltable ));
queryDataSourceCode.addRange(fieldNum(mandaltable , mandal )).value(custtable.mandal );
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

hi Chaitanya,

thanks for reply…

it’ working properly…

Thanks & Regards

Ramesh