Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Error: Form EcoResCategory requires an active buffer

(1) ShareShare
ReportReport
Posted on by 93
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.
  • Yue Zhen Profile Picture
    Yue Zhen 93 on at
    Error: Form EcoResCategory requires an active buffer
    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
  • Yue Zhen Profile Picture
    Yue Zhen 93 on at
    Error: Form EcoResCategory requires an active buffer
    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
  • Verified answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    Error: Form EcoResCategory requires an active buffer
    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.
  • andreasraithel Profile Picture
    andreasraithel 4,822 Super User 2024 Season 2 on at
    Error: Form EcoResCategory requires an active buffer
    Hy,
    can you describe the business requirement behind that?
     
    Herzliche Grüße / kind regards,
     
    Andreas Raithel
    D365FO Solution Architect

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans