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

Adding fields to On-Hand List form - Extension on InventDimCtrl_Frm_OnhandItem

(0) ShareShare
ReportReport
Posted on by 55

Hi All, 

We have two custom fields on 'InventTable' for 'Manufacturer' and 'Manufacturer ID'. Our goal is to add these two fields to the grid on On-Hand List form. Since 'InventTable_DS' is already a data source on the form, I've added the two fields to the grid, and based on the following posts, added the fields to the query as 'group by' fields. 

The suggestion in this post was to add the fields as 'group by' fields:

   

In this and other posts I've seen, this was done through a Coc code extension on InventDimCtrl_Frm_OnhandItem:

   

I've followed the above suggestions and created a code extension to add the fields to the form query: 

[ExtensionOf(classStr(InventDimCtrl_Frm_OnhandItem))]
final class InventDimCtrl_Frm_OnhandItem_CS_Extension
{

    public void modifyQuery(
        FormDataSource _inventSum_DS,
        FormDataSource _inventDim_DS)
    {
        next modifyQuery(_inventSum_DS, _inventDim_DS);
        
        Query inventSumQuery = _inventSum_DS.query();
        QueryBuildDataSource inventTable_qbds = inventSumQuery.dataSourceTable(tableNum(InventTable));

        if (inventTable_qbds)
        {
            inventTable_qbds.addGroupByField(fieldNum(InventTable, CS_Manufacturer));
            inventTable_qbds.addGroupByField(fieldNum(InventTable, CS_ManufacturerItemId));
        }

    }

}

When the form loads, the new columns for 'Manufacturer' and 'Manufacturer ID' are populated and have the correct values in them. The issue is this; If any filters are applied on the grid, or column sorted/filtered, then the value in the two columns goes blank. For example, hitting 'Apply' in the filters pane causes the values to go blank, but they return on hitting 'Reset.'

If I add 'Manufacturer' and 'Manufacturer ID' to the filter pane, and 'Apply' it still causes the fields to go blank. Oddly, filtering on a value in these filter pane fields gets the correct records, the columns are just visually blank in the grid.

I'm assuming that applying any filters to the grid is removing the fields I've added, but I'm not sure where exactly. There must be another method I need to extend, but it is not mentioned in other posts about extending the On-Hand List that I've found.

I took a trace of hitting 'Apply' and a trace for 'Reset' in the filter pane, and both traces show the same call to my custom code. And both queries from the trace get the same results when I run them in SQL. 

If anyone has any experience with extending this form, any help would be greatly appreciated. Thanks! 

 

I have the same question (0)
  • Verified answer
    id365font Profile Picture
    398 on at

    Hello,

    I have done this but using another method. Try to use it in the following method instead of yours:

    [ExtensionOf(classStr(InventDimCtrl_Frm_OnHand))]
    final class InventDimCtrl_Frm_OnHand_Extension
    {
        public void modifyQueryBasedOnDatasourceName(
            Query          _inventSum_DS_Query,
            str            _inventSum_DS_Name,
            FormDataSource _inventDim_DS)
        {
            next modifyQueryBasedOnDatasourceName(_inventSum_DS_Query, _inventSum_DS_Name, _inventDim_DS);
    
            Query query  = _inventSum_DS_Query;
    
            if (groupByNameAlias)
            {
                QueryBuildDataSource inventTableDataSource = query.dataSourceTable(tableNum(InventTable));
    
                if (inventTableDataSource)
                {
                    query.dataSourceTable(tableNum(InventTable)).addGroupByField(fieldNum(InventTable, CS_Manufacturer));
                    query.dataSourceTable(tableNum(InventTable)).addGroupByField(fieldNum(InventTable, CS_ManufacturerItemId));
                }
            }
    
        }
    }

  • Cody M Profile Picture
    55 on at

    Hi Ivan,

    That worked perfectly, thank you!!

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 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans