I got a requirement like I want to filter the warehouse based on site. Here I have to show standard lookup. So I follow the standard code. It is already written in purchTable.
location field:
class InventLocationId { public void lookup(FormControl _formControl, str _filterStr) { if (purchTable.InventSiteId) { InventLocation::lookupBySiteIdAllTypes(_formControl, purchTable.InventSiteId); } } } //lookupBySiteIdAllTypes method from inventLocation table. public static void lookupBySiteIdAllTypes(FormStringControl _ctrl, InventSiteId _inventSiteId) { SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventLocation), _ctrl); ListEnumerator listEnumerator = List::create(InventLocation::standardLookupFields()).getEnumerator(); while (listEnumerator.moveNext()) { sysTableLookup.addLookupfield(fieldName2id(tableNum(InventLocation), listEnumerator.current())); } sysTableLookup.parmQuery(InventLocation::standardLookupBySiteIdQuery(_inventSiteId)); sysTableLookup.performFormLookup(); } //standardLookupFields method from InventLoaction table. Here we get the field from autoLookup group from table. public static container standardLookupFields() { List list = new List(Types::String); SysDictFieldGroup sysDictFieldGroup = new SysDictFieldGroup(tableNum(InventLocation), tableFieldgroupStr(InventLocation, AutoLookup)); Counter numberOfFields = sysDictFieldGroup.numberOfFields(); Counter i; for (i=1; i<=numberOfFields; i++) { list.addEnd(fieldId2name(tableNum(InventLocation),sysDictFieldGroup.field(i))); } return list.pack(); } //standardLookupBySiteIdQuery method is used to filer the query based on site. public static Query standardLookupBySiteIdQuery(InventSiteId _inventSiteId) { Query query = new Query(); QueryBuildDataSource queryBuildDataSource; queryBuildDataSource = query.addDataSource(tableNum(InventLocation)); if (_inventSiteId) { queryBuildDataSource.addRange(fieldNum(InventLocation,InventSiteId)).value(_inventSiteId); } return query; }
Keep daxing!!
No comments:
Post a Comment