Implement lookup through event handler
If you want to write a lookup through the event handler. Follow the following code;
[FormControlEventHandler(formControlStr(SalesTable, SalesLine_CostSheetId), FormControlEventType::Lookup)]
public static void SalesLine_CostSheetId_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query;
QueryBuildDataSource qbdsFabCostSheetsCalculation;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;
FormControlCancelableSuperEventArgs formControlCancelSuper;
query = new Query();
formControlCancelSuper = e as FormControlCancelableSuperEventArgs;
formControlCancelSuper.CancelSuperCall();
sysTableLookup = SysTableLookup::newParameters(tableNum(FabCostSheetsCalculation), sender);
sysTableLookup.addLookupField(fieldNum(FabCostSheetsCalculation, CostSheetId));
qbdsFabCostSheetsCalculation = query.addDataSource(tableNum(FabCostSheetsCalculation));
qbdsFabCostSheetsCalculation.addRange(fieldNum(FabCostSheetsCalculation,Status)).value(queryValue(FabCostWorkflowStatus::Approved));
FormDataSource salesLine_ds = sender.formRun().dataSource("SalesLine");
SalesLine salesLine = salesLine_ds.cursor();
qbdsFabCostSheetsCalculation.addRange(fieldNum(FabCostSheetsCalculation,ArticleId)).value(queryValue(salesLine.ItemId));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup(); formControlCancelSuper.CancelSuperCall();
}
Thanks.
Comments