Lookup Method from Two Tables

Dear Friends,

I hv a problem in lookup Method. I hv External No that can lookup to table A and B . What should I write

ex:

Table A

No Name

MR-001 MRMR

MR-002 MRMRMR

and

Table B

No Name

MB-001 MB

MB-002 MBMB

so when i lookup i hv these data to choose

Lookup :

MR-001

MR-002

MB-001

MB-002

is it possible?

Create a union query in AOT and use it in your lookup method. See How to: Combine Data Sources in a Union Query for details about such queries.

Or change the approach - maybe users should first choose a type of record and then get a lookup from the right table (that can be modeled by relations).

You can build a lookup form with multiple datasources…

Hi Edi,

Try the below link.

http://waytoax.wordpress.com/2013/10/08/lookup-values-from-multitable/

how shoul i write the code?

i am writting the code below, but it return error

sysTableLookup=SysTableLookup::newParameters(tableNum(InventJournalTable), this);
sysTableLookup=SysTableLookup::newParameters(tableNum(FKT_Repacking), this);

query = new Query();
query.queryType(QueryType::Union);

queryDataSourceCode = query.addDataSource(tableNum(InventJournalTable));
queryDataSourceCode.unionType(UnionType::UnionAll); // Include duplicate records
queryDataSourceCode.fields().dynamic(false);
queryDataSourceCode.fields().clearFieldList();
queryDataSourceCode.fields().addField(fieldNum(InventJournalTable, JournalId));
queryDataSourceCode = query.addDataSource(tableNum(InventJournalTable));
queryDataSourceCode.addRange(fieldNum(InventJournalTable, JournalNameId)).value(“IMRC”);

queryDataSourceCode2 = query.addDataSource(tableNum(FKT_Repacking));
queryDataSourceCode2.unionType(UnionType::UnionAll); // Include duplicate records
queryDataSourceCode2.fields().dynamic(false);
queryDataSourceCode2.fields().clearFieldList();
queryDataSourceCode2.fields().addField(fieldNum(FKT_Repacking, No));
queryDataSourceCode2 = query.addDataSource(tableNum(FKT_Repacking));
queryDataSourceCode2.addRange(fieldNum(FKT_Repacking, No)).value(“MR*”);

SysTableLookup will not support lookup fields from multiple tables.