I have a custom filter combo box on the EcoResProductDetailsExtended form, this filter is based on an enum.
The filter field has a selectionChanged() event handler with the below logic.
internal final class ABCEcoResProductDetailsExtendedHandler
{
[FormControlEventHandler(formControlStr(EcoResProductDetailsExtended, ABCProductStateFilter), FormControlEventType::SelectionChanged)]
public static void ABCProductStateFilter_OnSelectionChanged(FormControl sender, FormControlEventArgs e)
{
FormComboBoxControl callerControl = sender as FormComboBoxControl;
FormRun form = callerControl.formRun();
FormDataSource inventTable_ds = form.dataSource(formDataSourceStr(EcoResProductDetailsExtended, InventTable));
ABCEcoResProductDetailsExtendedFilterHelper::applyProductStateFilter(inventTable_ds, callerControl.selection());
}
}
internal final class ABCEcoResProductDetailsExtendedFilterHelper
{
public static void applyProductStateFilter(FormDataSource _formDataSource, int selection)
{
QueryBuildDataSource inventTableDS, inventItemSetupDS;
inventTableDS = SysQuery::findOrCreateDataSource(_formDataSource.query(), tableNum(InventTable));
inventTableDS.clearLinks();
switch (selection)
{
case ABCProductStateFilter::Active :
inventItemSetupDS = inventTableDS.addDataSource(tableNum(ABCInventItemSetupStoppedUnion));
inventItemSetupDS.addLink(fieldNum(InventTable, ItemId), fieldNum(ABCInventItemSetupStoppedUnion, ItemId));
inventItemSetupDS.joinMode(JoinMode::NoExistsJoin);
inventItemSetupDS.relations(false);
break;
case ABCProductStateFilter::StoppedInvent :
inventItemSetupDS = inventTableDS.addDataSource(tableNum(InventItemInventSetupStopped));
inventItemSetupDS.addLink(fieldNum(InventTable, ItemId), fieldNum(InventItemInventSetupStopped, ItemId));
inventItemSetupDS.joinMode(JoinMode::ExistsJoin);
inventItemSetupDS.relations(false);
break;
case ABCProductStateFilter::StoppedPurch :
inventItemSetupDS = inventTableDS.addDataSource(tableNum(InventItemPurchSetupStopped));
inventItemSetupDS.addLink(fieldNum(InventTable, ItemId), fieldNum(InventItemPurchSetupStopped, ItemId));
inventItemSetupDS.joinMode(JoinMode::ExistsJoin);
inventItemSetupDS.relations(false);
break;
case ABCProductStateFilter::StoppedSales :
inventItemSetupDS = inventTableDS.addDataSource(tableNum(InventItemSalesSetupStopped));
inventItemSetupDS.addLink(fieldNum(InventTable, ItemId), fieldNum(InventItemSalesSetupStopped, ItemId));
inventItemSetupDS.joinMode(JoinMode::ExistsJoin);
inventItemSetupDS.relations(false);
break;
case ABCProductStateFilter::All:
break;
}
_formDataSource.executeQuery();
}
}
I know I am doing something wrong, if anyone has had this issue before some guidance would be greatly appreciated.