This post shows how to create lookup for ReferenceGroupControl using extensions.
All we need to do is to register event handler for lookup function and make a lookup little bit differently as shown below.
After handler is registered use the following code.
[FormControlEventHandler(formControlStr(MyWorker, MyWorker_HcmWorkerRecId), FormControlEventType::Lookup)]
public static void MyWorker_HcmWorkerRecId_OnLookup(FormControl sender, FormControlEventArgs e)
{
MyClass::createLookup(sender);
FormControlCancelableSuperEventArgs cancelableArgs = e as FormControlCancelableSuperEventArgs;
cancelableArgs.CancelSuperCall();
}
private static void createLookup(FormReferenceGroupControl _ctrl)
{
SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tablenum(HcmWorker), _ctrl);
Query query = new Query();
sysTableLookup.addLookupfield(fieldNum(HcmWorker, PersonnelNumber));
query.addDataSource(tablenum(HcmWorker));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
All we need to do is to register event handler for lookup function and make a lookup little bit differently as shown below.
After handler is registered use the following code.
[FormControlEventHandler(formControlStr(MyWorker, MyWorker_HcmWorkerRecId), FormControlEventType::Lookup)]
public static void MyWorker_HcmWorkerRecId_OnLookup(FormControl sender, FormControlEventArgs e)
{
MyClass::createLookup(sender);
FormControlCancelableSuperEventArgs cancelableArgs = e as FormControlCancelableSuperEventArgs;
cancelableArgs.CancelSuperCall();
}
private static void createLookup(FormReferenceGroupControl _ctrl)
{
SysReferenceTableLookup sysTableLookup = SysReferenceTableLookup::newParameters(tablenum(HcmWorker), _ctrl);
Query query = new Query();
sysTableLookup.addLookupfield(fieldNum(HcmWorker, PersonnelNumber));
query.addDataSource(tablenum(HcmWorker));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}