Custom/Change-standard lookup field of a standard form using register override method
/// <summary>
/// Extension of SalesTable form.
/// </summary>
[ExtensionOf(formStr(SalesTable))]
final class LSSalesTableFormV1_Extension
{
/// <summary>
/// init method.
/// </summary>
public void init()
{
next init();
// CR 4526 - start.
LSParameters lsParameters;
boolean ret;
FormRun formRun;
FormDataSource salesTable_ds;
SalesTable salesTableLoc;
lsParameters = LSParameters::find();
ret = lsParameters.SalesCumulativeDiscount ? true : false;
formRun = this;
salesTable_ds = formRun.dataSource(formDataSourceStr(SalesTable, SalesTable));
if(LSParameters::find().ExternalItemNumberinSOLine == NoYes::Yes)
{
FormStringControl SalesLine_ItemId = this.design().controlName(formControlStr(SalesTable, SalesLine_ItemId));
SalesLine_ItemId.registerOverrideMethod(methodStr(FormDataObject, lookup), formMethodStr(SalesTable, LSSalesLine_ItemId));
}
}
public void LSSalesLine_ItemId(FormStringControl _formControl)
{
Query query = new Query();
QueryBuildDataSource qbds,qbds2;
QueryBuildRange qbr;
SysTableLookup sysTableLookup;
qbds = query.addDataSource(tableNum(LSInventTableExternalItem));
//qbds.addRange(fieldNum(InventTable, ItemType)).value("Item");
//qbds2 = qbds.addDataSource(tableNum(CustVendExternalItem));
//qbds2.relations(false);
//qbds2.joinMode(JoinMode::OuterJoin);
//qbds2.addLink(fieldNum(CustVendExternalItem, ItemID), fieldNum(InventTable, ItemID));
sysTableLookup = SysTableLookup::newParameters(tableNum(LSInventTableExternalItem), _formControl);
sysTableLookup.addLookupfield(fieldNum(LSInventTableExternalItem, ItemId));
sysTableLookup.addLookupfield(fieldNum(LSInventTableExternalItem, NameAlias));
sysTableLookup.addLookupfield(fieldNum(LSInventTableExternalItem, ItemType));
//sysTableLookup.addLookupfield(fieldNum(LSInventTableExternalItem, ExternalItemId));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
}
I hope this blog of DynamicsCommunity101 we learnt the Custom/Change-standard lookup field of a standard form using register override method