web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Error: Form EcoResCategory requires an active buffer

(1) ShareShare
ReportReport
Posted on by 147
This is a question on Dynamics 365 FO.

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:
 
internal final class MainAccountExt
{
    /// <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;
        FormControlCancelableSuperEventArgs event;
        event = e as FormControlCancelableSuperEventArgs;
        // Select from EcoResCategory table where the CategoryHierarchy == E-Invoice
        qbds = query.addDataSource(tableNum(EcoResCategory));
        qbr = qbds.addRange(fieldNum(EcoResCategory,CategoryHierarchy));
        qbr.value('68719480517');
        qbr1 = qbds.addRange(fieldNum(EcoResCategory, Level));
        qbr1.value('3');
        // Specify the name of the table the lookup should show data from.
        SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(EcoResCategory), sender, true);
        // Add field that should be shown on lookup form
        sysTableLookup.addLookupfield(fieldNum(EcoResCategory, Code));
        sysTableLookup.addLookupfield(fieldNum(EcoResCategory, Name));
        // parmQuery() is required to specify the data that should be displayed in the lookup form (dropdown list)
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
        event.CancelSuperCall();
    }
    /// <summary>
    ///
    /// </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());
    }
    // Jumpref method for View Details function
    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));
        if(ecoResCategory)
        {
            // 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 = new Args(formStr(EcoResCategory));
            //args.record(ecoResCategory2);
            //info(strFmt(/%1/, args));
            //args.caller(formRun);
            //menuFunction = new MenuFunction(menuitemDisplayStr(EcoResCategoryHierarchyDetails), MenuItemType::Display);
            //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.
I have the same question (0)
  • AR-01121610-0 Profile Picture
    4,967 Moderator on at
    Hy,
    can you describe the business requirement behind that?
     
    Herzliche Grüße / kind regards,
     
    Andreas Raithel
    D365FO Solution Architect
  • Verified answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Instead of this much code you can simply check how the SalesCategory at Sales order or Sales quotation is built. Similar way you can create the category hierarchy lookup and view details will come based on relation provided.
  • Yue Zhen Profile Picture
    147 on at
    Hi Andreas,
     
    My requirement is I will need to create the Classification lookup field in the Main Account form. The Classification field will display a list of the Code and Name column. The data of Classification lookup field is taken from the Product Category, which is the Category Hierarchies form. There is another requirement that when users right-click the not empty Classification lookup field and select View Details, the users should be navigated to the Category Hierarchies form with the Code selected in the Classification field.

    My current progress is I can create the field and its SysLookupField. It is achieved by using the
    MainAccount_ADS_Classification_OnLookup() method. To create View Details features, I will need to add the Jumpref() method. But it keeps giving me "Form EcoResCategory requires an active buffer" error.

    Regards,
    Yue Zhen
  • Yue Zhen Profile Picture
    147 on at
    Hi Mr Bharani, 

    Thank you for the method suggested. It worked for me after I set the project Database Synchronization property to True.

    ​​​​​​​Best regards,
    Yue Zhen

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 663 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 540 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans