Conditional Based LookUp()

Hi All,

I’m facing serious problem to make a lookup() method that should display primary customer(single customer) and customer under the customer(multiple).

for eg:

I’ve customer US-008 under this customer I’ve added three customer( say Cust-1, Cust-2,Cust-3) for the Authorized Sub contractors customer. When I’m releasing the sales agreement for the primary customer(US-008). In the lookup I should able to see four customer that means ( US-008, Cust-1, Cust-2,Cust-3).

How to achieve this I’ve made a lookup() method in the field design in form but also the code but still I’m just getting only the Primary customer.

for the above display form has three customers and in below form I can able to choose only one customer.

In my second screen shoot I’m trying to release the customers but it’s showing only one customer I want this to displayed in lookup for all the four customer accordingly.

You can use sysTableLookup class to get the lookup and based on your table relation, write the query to get expected lookup.

Thank you Vishal,

I’ve achieved the result. Through the below code.

void lookup(FormControl control, str _filterStr)
{
//super(control, _filterStr);
Query query = new Query();
QueryRun qr;
QueryBuildDataSource queryBuildDataSource;
QueryBuildDataSource queryBuildDataSource2;
QueryBuildRange queryBuildRange;
QueryBuildRange queryBuildRange2;
SysTableLookup sysTableLookup;
CW005_LookupTemp lookUp;
SalesAgreementHeader salesAgreementHeaderInstance;
CW005_AuthorizedSubcontractingCustomers authSubCont;
;

delete_from lookUp;
queryBuildDataSource = query.addDataSource(tableNum(SalesAgreementHeader));
queryBuildDataSource2 = query.addDataSource(tablenum(CW005_AuthorizedSubcontractingCustomers));

//Joining the tables
queryBuildDataSource2.joinMode(JoinMode::InnerJoin);

//linking the two table through the common fields
//queryBuildDataSource.addLink(fieldNum(SalesAgreementHeader,RecId),fieldNum(CW005_AuthorizedSubcontractingCustomers,AgreementHeaderDefault));

//setting the range in the datasource one
queryBuildRange = queryBuildDataSource.addRange(fieldnum(SalesAgreementHeader,RecId));
queryBuildRange.value(queryValue(salesAgreementHeader.RecId));

//setting the range in the datasource two
queryBuildRange2 = queryBuildDataSource2.addRange(fieldNum(CW005_AuthorizedSubcontractingCustomers, AgreementHeaderDefault));
queryBuildRange2.value(queryValue(salesAgreementHeader.RecId));

// running into the query dataset
qr = new QueryRun(query);
while(qr.next())
{
authSubCont = qr.get(tableNum(CW005_AuthorizedSubcontractingCustomers));

select salesAgreementHeaderInstance where salesAgreementHeaderInstance.recid == authSubCont.AgreementHeaderDefault
&& salesAgreementHeaderInstance.CustAccount != authSubCont.CustTable;

if(salesAgreementHeaderInstance)
{
lookUp.CustAccount = salesAgreementHeaderInstance.CustAccount;
lookUp.CustAccount = authSubCont.CustTable;
lookUp.Insert();
//info(strFmt(’%1’, lookUp.CustAccount));
}
else
{
salesAgreementHeaderInstance = qr.get(tableNum(SalesAgreementHeader));
select firstOnly CustAccount from salesAgreementHeaderInstance where salesAgreementHeaderInstance.RecId == salesAgreementHeader.RecId;

lookUp.CustAccount = salesAgreementHeaderInstance.CustAccount;
lookUp.Insert();
//info(strFmt(’%1’, lookUp.CustAccount));
}

}

//Create an instance of SysTableLookup with the form control passed in
sysTableLookup = SysTableLookup::newParameters(tablenum(CW005_LookupTemp), control);

//Add the fields to be shown in the lookup form
sysTableLookup.addLookupfield(fieldnum(CW005_LookupTemp, CustAccount), true);

// Perform lookup
sysTableLookup.performFormLookup();

}