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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to add/remove Filter on Display Methods!!!

(0) ShareShare
ReportReport
Posted on by 1,883

Dear All - I have customized display method on InventSum table and I used this  display method for new string control in InventOnhandItem Form. I created context() method on same string control for removing filter but still the filter is not removed on display method. Please check the code and let me know any corrections...

void context()
{
    int selectedMenu;
    real test;
    formrun fr;
    Args ag;
    Itemname strtext;
    querybuilddataSource qb1;
    queryrun qr;
    query q;
    PopupMenu menu = new PopupMenu(element.hWnd());
    int a = menu.insertItem('Find');
    int b = menu.insertItem('Filter');
    int c = menu.insertItem('Remove Filter');


    selectedMenu = menu.draw();

    switch (selectedMenu)
    {
        case -1:
            break;
        case a:
            ag = new args('SysformSearch');
            fr = new formrun(ag);
            fr.run();
            fr.wait();
            strtext = fr.design().controlName('FindEdit').valueStr();
            if(strtext)
            {
                q = inventSum_Ds.query();
                qb1 =q.dataSourceTable(tablenum(InventSum));
                QB1.addRange(FieldNum(InventSum,ItemId)).value(SySQuery::value(strtext));
                INVENTSUM_DS.query(Q);
                INVENTSUM_ds.executeQuery();
            }
            break;
        case b:
            InventSum_DS.filter(FieldNum(InventSum,ItemId),Sysquery::value(InventSum.inventItemGroupName()));
            break;

        case c :
            InventSum_DS.removeFilter();
            break;
        Default:
            break;

    }
}

*This post is locked for comments

I have the same question (0)
  • Denis Macchinetti Profile Picture
    16,444 on at
    RE: How to remove Filter on Display Methods!!!

    Hi Faqru

    After removeFilter, try to add also the Research method.

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to remove Filter on Display Methods!!!

    Hello Denis - Thanks for your replay. I added Research method in case c after InventSum_DS.removeFilter(); still filter is not removed. I also try right click and remove filter on my form but the result is same...

  • Denis Macchinetti Profile Picture
    16,444 on at
    RE: How to remove Filter on Display Methods!!!

    Hi Faqru

    If you try to filter the ItemID and remove through the form, it works?

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to remove Filter on Display Methods!!!

    I can filter ItemID and get the Itemgroup and Name. If you look at InventSum table there is no fields ItemGroup and Name. Actually I wants to know on hand inventory based on its name or group. For that I create display methods on InventSum table. The only thing I need to add/remove the filter for my display methods in my form. Check my code also On InventSum table

    display Name inventItemGroupName()
    {
        return InventItemGroup::find(this.itemGroupId()).Name;
    }

    code for this.itemGroupId()

    display ItemGroupId itemGroupId()
    {
        InventItemGroupItem inventItemGroup;

        select ItemGroupId from inventItemGroup where inventItemGroup.ItemId == this.ItemId
             &&  inventItemGroup.ItemDataAreaId  == this.dataAreaId;

        return inventItemGroup.ItemGroupId;
    }

  • Suggested answer
    Denis Macchinetti Profile Picture
    16,444 on at
    RE: How to remove Filter on Display Methods!!!

    Hi Faqru

    Now, I got you.

    You have added two Display Fields, inventItemGroupName and itemGroupId and you want to Filter them.

    But, you can't based your filter on ItemId field.

    I suggest to check this post, www.andesoft.net/how-to-filter-display-fields-on-a-form-on-dynamics-ax-2012

    Explain very well how to Filter through a Display Field.

    Practically, you have to "extend" the InventSum_ds.Query() and add the tables involved in the Display Method.

  • Kanagaraj A Profile Picture
    1,254 on at
    RE: How to remove Filter on Display Methods!!!

    Hi Faqruddin ,

    Could you try with below link? it may solve your problem.

    http://axhelpdesk.blogspot.in/2013/11/how-to-add-filter-functionality-to.html

     

    Thanks,

     

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to remove Filter on Display Methods!!!

    Thanks for your replies. In above code, I need a logic to filter with filed "Name" which exists in InventItemGroup. Really appreciate if you could help me with the logic and code.

    0714.item.jpg

  • Denis Macchinetti Profile Picture
    16,444 on at
    RE: How to remove Filter on Display Methods!!!

    Hi Faqru

    As I told above, you have to start from the InventSum_ds.Query and add the Tables involved in the Display method.

    Something like below :

    q   = InventSum_ds.query();
    qb1 = q.dataSourceTable(tablenum(InventSum));
    qb1 = qb1.addDataSource(TableNum(InventItemGroupItem));
    qb1.relations( false );
    qb1.addLink(FieldNum(InventSum,ItemId),FieldNum(InventItemGroupItem,ItemId));
    qb1.joinMode(JoinMode::ExistsJoin);

    qb2= qb1.addDataSource( tableNum( InventItemGroup) );
    qb2.relations( false);
    qb2.addLink( fieldNum(InventItemGroupItem, ItemGroupId), fieldNum(InventItemGroup, ItemGroupId));
    qb2.joinMode(JoinMode::ExistsJoin);
    qb2.addRange(FieldNum(InventItemGroup,name)).value(QueryValue(strtext));

    InventSum_ds.query(Q);
    InventSum_ds.executeQuery();
     

    I didn't tested it, but for sure it's a good start!

    Enjoy!

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to remove Filter on Display Methods!!!

    Hi Denis - Thanks for your reply. But I wants to filter the Filed Name. I do agree adding more datasets for the InventSum_ds.Query().  In case b how do I filter Name filed from InventItemGroup. Please check this...

            case b:
                InventSum_DS.filter(FieldNum(InventSum,ItemId),Sysquery::value(InventSum.inventItemGroupName()));
                break;


  • Denis Macchinetti Profile Picture
    16,444 on at
    RE: How to remove Filter on Display Methods!!!

    Hi

    Simply copy & paste my code above.

    Again, check better because I don't made any test.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans