There are two Ways to Override an existing Lookup Method.
- Using a Form Control Event Handler
- Using Chain Of Command
Override An Existing Lookup Using An Event Handler

Right click the ‘OnLookup’ node and select ‘Copy event handler method’ from the dialog’.

paste the text in your clipboard into the New class.
Eg:
class digivertCustTable_Form_Handler
{
/// /// ///
///
///
[FormControlEventHandler(formControlStr(CustTable, Posting_CustGroup), FormControlEventType::Lookup)]
public static void Posting_CustGroup_OnLookup(FormControl sender, FormControlEventArgs e)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustGroup), sender);
// Add the lookup columns
sysTableLookup.addLookupfield(fieldNum(CustGroup, CustGroup));
sysTableLookup.addLookupfield(fieldNum(CustGroup, Name));
sysTableLookup.addLookupfield(fieldNum(CustGroup, PaymTermId));
// Run the lookup
sysTableLookup.performFormLookup();
//cancel the call to super() to prevent the system from trying to show
//the lookup form twice and cause an error.
FormControlCancelableSuperEventArgs cancelableSuperEventArgs = e as FormControlCancelableSuperEventArgs;
cancelableSuperEventArgs.CancelSuperCall();
}
}
Override An Existing Lookup Using Chain of Command
we will look at how to override an existing lookup using Chain Of Command.
[ExtensionOf(formStr(CustTable))]
final class digivertCustTable_Form_Extension
{
public void init()
{
next init();
FormStringControl custGroupControl = this.design().controlName(formControlStr(CustTable, Posting_CustGroup));
custGroupControl.registerOverrideMethod(methodStr(FormDataObject, lookup), formMethodStr(CustTable, overridenCustGroupLookup));
}
public void overridenCustGroupLookup(FormStringControl _formControl)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustGroup), _formControl);
// Add the lookup columns
sysTableLookup.addLookupfield(fieldNum(CustGroup, CustGroup));
sysTableLookup.addLookupfield(fieldNum(CustGroup, Name));
sysTableLookup.addLookupfield(fieldNum(CustGroup, PaymTermId));
// Run the lookup
sysTableLookup.performFormLookup();
}
}
For more information you can reach out to us at care@digivert.in or WhatsApp us at + 91 9990281800
