I created a field named Classification in the MainAccount form. On the field, I need to create a View Details feature to navigate to the Category Hierarchies form (EcoResCategory). I have written the following code, but I encountered an error saying that /Form EcoResCategory requires an active buffer/. My code is as follow:
{
/// <summary>
/// Add the Lookup Classification field to the MainAccount form.
/// </summary>
/// <param name=/sender/></param>
/// <param name=/e/></param>
[FormControlEventHandler(formControlStr(MainAccount, MainAccount_ADS_Classification), FormControlEventType::Lookup)]
public static void MainAccount_ADS_Classification_OnLookup(FormControl sender, FormControlEventArgs e)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildRange qbr, qbr1;
event = e as FormControlCancelableSuperEventArgs;
qbds = query.addDataSource(tableNum(EcoResCategory));
qbr = qbds.addRange(fieldNum(EcoResCategory,CategoryHierarchy));
qbr.value('68719480517');
qbr1.value('3');
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(EcoResCategory), sender, true);
sysTableLookup.addLookupfield(fieldNum(EcoResCategory, Code));
sysTableLookup.addLookupfield(fieldNum(EcoResCategory, Name));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
///
/// </summary>
/// <param name=/sender/></param>
/// <param name=/e/></param>
[FormEventHandler(formStr(MainAccount), FormEventType::Initialized)]
public static void MainAccount_OnInitialized(xFormRun sender, FormEventArgs e)
{
FormStringControl formStrCtrl = sender.design().controlName(formControlStr(MainAccount, MainAccount_ADS_Classification));
formStrCtrl.registerOverrideMethod(methodStr(FormStringControl, jumpref), methodStr(MainAccountExt, jumpref), new MainAccountExt());
}
public void jumpref(FormControl _formControl)
{
MenuFunction menuFunction;
FormRun formRun, targetFormRun;
//Args args = new Args();
Args args;
EcoResCategory ecoResCategory, ecoResCategory2;
//ecoResCategory = EcoResCategory::findByCode(_formControl.valueStr(), 68719480517);
select * from ecoResCategory where ecoResCategory.Code == _formControl.valueStr();
ecoResCategory2 = EcoResCategory::find(ecoResCategory.CategoryHierarchy);
info(strfmt(/EcoResCategory: %1/, ecoResCategory2));
{
// Specifying which record the form should display or operate on
args.record(ecoResCategory2);
args.lookupRecord(ecoResCategory2);
menuFunction = new MenuFunction(menuItemActionStr(RetailCategoryDetailsLauncher), MenuItemType::Action);
menuFunction.copyCallerQuery(CopyCallerQuery::Yes);
menuFunction.formViewOption(FormViewOption::Details);
menuFunction.run(args);
//args.record(ecoResCategory2);
//info(strFmt(/%1/, args));
//args.caller(formRun);
//menuFunction.run(args);
else
{
menuFunction = new MenuFunction(menuItemDisplayStr(EcoResCategoryHierarchyListPage), MenuItemType::Display);
menuFunction.run(args);
}
}
I would like to ask what is the active buffer and how to get it. Thank you for any kind helping.