Here is my code. As you can see, I already have the lookup for another instance of the Problem Sub Type on a different tab. The thing is, the tab that I'm trying to get it to work on, the formcontrol is inside a field group like I mentioned. As soon as I add the code at the bottom, it give me the error
public class InventNonConformanceTable_Form_Handlers
{
///
///
///
///
///
[FormControlEventHandler(formControlStr(InventNonConformanceTable, InventNonConformanceTable_TCI_InventRootSubTypeId), FormControlEventType::Lookup)]
public static void InventNonConformanceTable_TCI_InventRootSubTypeId_OnLookup(FormControl sender, FormControlEventArgs e)
{
//Specify the name of the table the lookup should show data from.
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(TCI_InventRootSubType), sender);
FormRun formRun = sender.formRun();
FormDataSource dataSoruce_ds = sender.formRun().dataSource();
//To get the buffer use below code.
//TableName tableBuffer = dataSoruce_ds.cursor();
//To get control value refer to beloe code
FormControl controlName = formRun.design().controlName("InventNonConformanceTable_TCI_InventRootTypeId");
//Cancel super
FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
event.CancelSuperCall();
//Create a new query
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
//Specify the name of the table the lookup should show data from.
queryBuildDataSource = query.addDataSource(tableNum(TCI_InventRootSubType));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(TCI_InventRootSubType,TCI_InventRootTypeId));
queryBuildRange.value(queryValue(controlName.valueStr()));
//Specify which fields should be shown in the lookup form.
// field returned is the first field referenced
sysTableLookup.addLookupfield(fieldNum(TCI_InventRootSubType, TCI_InventRootSubTypeId));
sysTableLookup.addLookupfield(fieldNum(TCI_InventRootSubType, Description));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
///
///
///
///
///
[FormControlEventHandler(formControlStr(InventNonConformanceTable, InventNonConformanceTable_TCI_InventProblemSubTypeId), FormControlEventType::Lookup)]
public static void InventNonConformanceTable_TCI_InventProblemSubTypeId_OnLookup(FormControl sender, FormControlEventArgs e)
{
//Specify the name of the table the lookup should show data from.
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(TCI_InventProblemSubType), sender);
FormRun formRun = sender.formRun();
FormDataSource dataSoruce_ds = sender.formRun().dataSource();
//To get the buffer use below code.
//TableName tableBuffer = dataSoruce_ds.cursor();
//To get control value refer to beloe code
FormControl controlName = formRun.design().controlName("InventNonConformanceTable_InventTestProblemTypeId");
//Cancel super
FormControlCancelableSuperEventArgs event = e as FormControlCancelableSuperEventArgs;
event.CancelSuperCall();
//Create a new query
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
//Specify the name of the table the lookup should show data from.
queryBuildDataSource = query.addDataSource(tableNum(TCI_InventProblemSubType));
queryBuildRange = queryBuildDataSource.addRange(fieldNum(TCI_InventProblemSubType,ProblemTypeId));
queryBuildRange.value(queryValue(controlName.valueStr()));
//Specify which fields should be shown in the lookup form.
// field returned is the first field referenced
sysTableLookup.addLookupfield(fieldNum(TCI_InventProblemSubType, ProblemSubTypeId));
sysTableLookup.addLookupfield(fieldNum(TCI_InventProblemSubType, Description));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
///
///
///
///
///
[FormControlEventHandler(formControlStr(InventNonConformanceTable, ProblemInformation_TCI_InventProblemSubTypeId), FormControlEventType::Lookup)]
public static void ProblemInformation_TCI_InventProblemSubTypeId_OnLookup(FormControl sender, FormControlEventArgs e)
{
}
}
