How To Override An Existing Lookup Method: Chain Of Command
Today we have a requirement there is one control over there a standard has written a lookup method now we want to overwrite it
We tried with the event handler but no luck then we got chance to use register overwirte lookup topology so what we have done
1) Create a extension of form
2) Write the custom lookup logic
3) then call the particular method on the form level init method
below are the example
[ExtensionOf(formStr(EntAssetWorkOrderTableCreateRelated))]
Final class IHSEntAssetWorkOrderTableCreateRelatedFrm_Extension
{
void init()
{
next init();
// FromWorkOrderLine.registerOverrideMethod(methodStr(FormDataObject, lookup), formMethodStr(EntAssetWorkOrderTableCreateRelated, ihsFromWorkOrderLineLookup));
}
FromWorkOrderLine :- Please note this will be the control name where the standard has written the lookup
=======================================================================
// this lookup will buy pass the standard look up method written over the form control
public void ihsFromWorkOrderLineLookup(FormControl _callingControl)
{
// FormReferenceControl referenceControl = sender as FormReferenceControl;
SysReferenceTableLookup lookup = SysReferenceTableLookup::newParameters(tableNum(EntAssetWorkOrderLine), _callingControl);
Query query = new Query();
// EntAssetWorkOrderTable fromWorkOrderTable = sender.dataSourceObject().cursor() as EntAssetWorkOrderTable;
QueryBuildDataSource qbdsWorkOrderLine = query.addDataSource(tableNum(EntAssetWorkOrderLine));
QueryBuildRange qbr = qbdsWorkOrderLine.addRange(fieldNum(EntAssetWorkOrderLine, WorkOrder));
QueryBuildRange qbrIHSManageDisposal = qbdsWorkOrderLine.addRange(fieldNum(EntAssetWorkOrderLine, IHSManageDisposal));
qbdsWorkOrderLine.addOrderByField(fieldNum(EntAssetWorkOrderLine, LineNumber));
qbr.value(SysQuery::value(fromWorkOrderTable.RecId));
qbrIHSManageDisposal.value(enum2Str(NoYes::Yes));
lookup.parmQuery(query);
lookup.addLookupfield(fieldNum(EntAssetWorkOrderLine, WorkOrder));
lookup.addLookupfield(fieldNum(EntAssetWorkOrderLine, LineNumber));
lookup.addLookupfield(fieldNum(EntAssetWorkOrderLine, Object));
lookup.addLookupfield(fieldNum(EntAssetWorkOrderLine, JobType));
lookup.performFormLookup();
}
}
Comments
Post a Comment