30 Kasım 2011 Çarşamba

AXAPTA multitable lookup

We can write a lookup and join two tables. So if we want  to show fields from second table at lookup list? Unfortunately Axapta's SysTableLookUp class cannot provide this feature. There is another class derived from SysTableLookUp named  SysMultiTableLookUp.

It's easy download and install it from this link. Sample is below:


public void Agreementlookup(FormControl _formControl, str _filterStr)
{
SMAAgreementTable SMAagreementTable;
Query query = new Query();
SysMultiTableLookup sysTableLookup;
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tablenum(SMAAgreementTable));
QueryBuildDataSource qbds2;
QueryBuildRange qbr;
;

qbds2=queryBuildDataSource.addDataSource(tablenum(B_AgreementCustomerTable));
qbds2.relations(true);

qbr=qbds2.addRange(fieldnum(B_AgreementCustomerTable, num));

qbr.value(strfmt('((Num == "%1") && (AccountCode == TableGroupAll::Table)) || (AccountCode == TableGroupAll::All)',
QueryValue(salesTable.CustAccount)));

sysTableLookup = SysMultiTableLookup::newParameters(_formControl,query);
sysTableLookup.addLookupfield(fieldnum(SMAAgreementTable, AgreementId),1);
sysTableLookup.addLookupfield(fieldnum(SMAAgreementTable, AgreementDescription),1);
sysTableLookup.addLookupfield(fieldnum(SMAAgreementTable, ProjId),1);
sysTableLookup.addLookupfield(fieldnum(B_AgreementCustomerTable, AccountCode),2);
sysTableLookup.addLookupfield(fieldnum(B_AgreementCustomerTable, Num),2);

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

Hiç yorum yok:

Yorum Gönder