Skip to main content

Notifications

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

InventOnhandItem form -

Posted on by 10
Hello Expert
In on-Hand form I added a new data source InventTableExpanded view after that I adjust the class 
 
[ExtensionOf(classStr(InventDimCtrl_Frm_OnHand))]
internal final class In_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)
            {

                QueryBuildDataSource qbds;
                qbds =inventTableDataSource.addDataSource(tableNum(In_InventTableExpanded));

                qbds.addLink(fieldNum(InventTable,itemid),fieldNum(In_InventTableExpanded,itemid));
                qbds.JoinMode(JoinMode::InnerJoin);

                query.dataSourceTable(tableNum(In_InventTableExpanded)).addGroupByField(fieldNum(In_InventTableExpanded, ItemId));
                query.dataSourceTable(tableNum(In_InventTableExpanded)).addGroupByField(fieldNum(In_InventTableExpanded, ProductName));

            }
        }

    }

}
 
and the field appeared but when I pressing on it to filter the next error appair 
 
  1. Column is not filterable.
 
Categories:
  • AI-26111618-0 Profile Picture
    AI-26111618-0 10 on at
    InventOnhandItem form -
    In_InventTableExpanded is a view added the form datasource it containes product name and description , so I cann't add relation in the view 
     
  • AI-26111618-0 Profile Picture
    AI-26111618-0 10 on at
    InventOnhandItem form -
     QueryBuildDataSource inventTableDataSource = query.dataSourceTable(tableNum(In_InventTableExpanded));
    But here in last code I  didn't add a new data source I just added a relation 
  • Martin Dráb Profile Picture
    Martin Dráb 230,030 Most Valuable Professional on at
    InventOnhandItem form -
    You still didn't tell us what you did in the form. Did you add a In_InventTableExpanded to the the form, set the InventTable as the value of Join Source property and did you bind the field to the In_InventTableExpanded data source?
     
    What you found that you debugged your code? Does inventTableDataSource variable have a value? What is the query string that you've generated by your code?
     
    Why do you change the join mode in code? You should do it in the data source property and remove the call of joinMode(). Also, you shouldn't be using addLink() - you should have a relation from In_InventTableExpanded to InventTable.
  • AI-26111618-0 Profile Picture
    AI-26111618-0 10 on at
    InventOnhandItem form -
    Thank you Marten , and sorry about the delay 
     
    I edited the code to be 
     
             next modifyQueryBasedOnDatasourceName(_inventSum_DS_Query, _inventSum_DS_Name, _inventDim_DS);
    
            Query query  = _inventSum_DS_Query;
    
            if (groupByNameAlias)
            {
                QueryBuildDataSource inventTableDataSource = query.dataSourceTable(tableNum(In_InventTableExpanded));
    
                if (inventTableDataSource)
                {
    
                    inventTableDataSource.addLink(fieldNum(InventTable,itemid),fieldNum(In_InventTableExpanded,itemid));
                    inventTableDataSource.JoinMode(JoinMode::InnerJoin);
    
                    query.dataSourceTable(tableNum(In_InventTableExpanded)).addGroupByField(fieldNum(In_InventTableExpanded, ProductName));
    
                }
            }
    
    but same issue exist , I can't filter the product name 
  • Martin Dráb Profile Picture
    Martin Dráb 230,030 Most Valuable Professional on at
    InventOnhandItem form -
    You said that "the field appeared", but you showed code unrelated to any form field; your code adds a query data source at runtime.
     
    If you've added a data source to a form and you want to adjust its query, your code is wrong. You need to get a reference to the existing query data source (e.g. query.dataSourceTable(tableNum(In_InventTableExpanded))) instead of ignoring the data source used by the field and adding an additional one (with addDataSource()).

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans