Hi all following code snippet for custom lookup. Copy the onlookup event handler and copy in extension class and the following code snippet
Field based
[FormControlEventHandler(formControlStr(Txxxx, Txxxx_ChildName), FormControlEventType::Lookup)]
public static void xxxxx_DssChildName_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource qbdsJoin;
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(DirPartyTable), sender);
qbds= query.addDataSource(tableNum(DirPartyTable));
qbdsJoin= qbds.addDataSource(tableNum(DirPartyRelationship));
//qbdsJoin.relations( false);
//qbdsJoin.fields().dynamic(NoYes::Yes);
// hcmWorkerCaller = HcmWorker::find(currentWorker());
// qbds.addRange(fieldNum(DirPartyTable, RecId)).value(int642Str(HcmWorker::find(currentWorker()).Person));
qbdsJoin.addRange(fieldNum(DirPartyRelationship, parentparty)).value(int642Str(HcmWorker::find(currentWorker()).Person));
qbdsJoin.addLink(fieldNum(DirPartyTable, RecId), fieldNum(DirPartyRelationship, childparty));
qbdsJoin.joinMode(JoinMode::InnerJoin);
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(DirPartyTable, Name), true);
sysTableLookup.addLookupfield(fieldNum(DirPartyTable, RecId));
sysTableLookup.performFormLookup();
FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
event.CancelSuperCall();
}
Reference based is as follow
[FormControlEventHandler(formControlStr(xxxxx, Txeee_dddd), FormControlEventType::Lookup)]
public static void ddddee_DSSPerson_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource qbdsJoin;
SysReferenceTableLookup _sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(DirPartyTable), sender);
qbds= query.addDataSource(tableNum(DirPartyTable));
qbdsJoin= qbds.addDataSource(tableNum(DirPartyRelationship));
//qbdsJoin.relations( false);
//qbdsJoin.fields().dynamic(NoYes::Yes);
// hcmWorkerCaller = HcmWorker::find(currentWorker());
// qbds.addRange(fieldNum(DirPartyTable, RecId)).value(int642Str(HcmWorker::find(currentWorker()).Person));
qbdsJoin.addRange(fieldNum(DirPartyRelationship, parentparty)).value(int642Str(HcmWorker::find(currentWorker()).Person));
qbdsJoin.addLink(fieldNum(DirPartyTable, RecId), fieldNum(DirPartyRelationship, childparty));
qbdsJoin.joinMode(JoinMode::InnerJoin);
_sysTableLookup.parmQuery(query);
_sysTableLookup.addLookupfield(fieldNum(DirPartyTable, Recid));
_sysTableLookup.addLookupfield(fieldNum(DirPartyTable, Name));
//, true);
// _sysTableLookup.addLookupfield(fieldNum(DirPartyTable, recid));
_sysTableLookup.performFormLookup();
FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
event.CancelSuperCall();
}
上一篇 零售类别管家,在#Dyn365FO中简化您对已发布产品的导入 / Retail category managers, Simplify your import of released products in #Dyn365FO
#Dyn365FO POS发票支付 / POS Invoice Pay #Dyn365FO 下一篇