Requirement: I had one Requirement where I wanted to filter the global addresses based on selected legal entity(Company). So by following below code we can get those addresses in lookup which are related to that specific legal entity.
[Form]
public class Form2 extends FormRun
{
[Control("String")]
class FormStringControl1
{
/// <summary>
///
/// </summary>
public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
CompanyInfo companyInfo;
OMInternalOrganization oMInternalOrganization;
DirOrganizationBase dirOrganizationBase;
DirPartyTable dirPartyTable;
DirPartyLocation DirPartyLocation;
LogisticsLocation logisticsLocation;
LogisticsPostalAddress logisticsPostalAddress;
companyInfo=CompanyInfo::findDataArea("USMF");
select oMInternalOrganization where oMInternalOrganization.RecId==companyInfo.RecId
join dirOrganizationBase where dirOrganizationBase.RecId==oMInternalOrganization.RecId
join dirPartyTable where dirPartyTable.RecId==dirOrganizationBase.RecId;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsPostalAddress), this);
sysTableLookup.addLookupField(fieldNum(LogisticsPostalAddress, Address));
queryBuildDataSource = query.addDataSource(tableNum(LogisticsPostalAddress));
while select DirPartyLocation where DirPartyLocation.Party==dirPartyTable.RecId
join logisticsLocation where logisticsLocation.RecId==DirPartyLocation.Location
join logisticsPostalAddress where logisticsPostalAddress.Location==logisticsLocation.RecId
{
// Info(strFmt("%1",logisticsPostalAddress.Address));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(LogisticsPostalAddress, RecId));
queryBuildRange.value(any2Str(logisticsPostalAddress.RecId));
}
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
}
}
No comments:
Post a Comment