Skip to main content

Notifications

Microsoft Dynamics AX forum
Answered

Multiselect Custom Lookup Filter

Posted on by 434

Hi, 

My Form is here shown below. I Used Two filters (From Date, To Date), and ( Site and Warehouse). When i used From and To Date filters it will filter the grid between the transaction date. If i use the Site and Warehouse filter. It is a Multiselect lookup filter. 

pastedimage1579617239812v1.png

I had selected the site no 1,12,2 but in my Warehouse Filter control it shows only 1 and 12 site and its warehouses. Because i had chosen the 1 and 12 site first. I need that all the site and warehouses i chosen at Site filter control in the warehouse filter lookup. 

pastedimage1579619429425v6.png

pastedimage1579620119109v7.png

This is my Warehouse filter control Lookup code.

public void lookup()
{
SysLookupMultiSelectCtrl slmsc;
Query query;
QueryBuildDataSource qbds;
List list;
ListIterator itr;
list = new List(Types::String);
list = strSplit(Site.valueStr(),";");
itr = new ListIterator(list);


query = new Query();
qbds = query.addDataSource(tableNum(InventLocation));
qbds.fields().addField(fieldNum(InventLocation,InventLocationId));
qbds.fields().addField(fieldNum(InventLocation,InventSiteId));


if(Site.valueStr()!="")
{
while(itr.more())
{
qbds.addRange(fieldNum(InventLocation, inventsiteid)).value(itr.value());
itr.next();
}
}

else
{
throw error('Please choose Site');
}
slmsc = SysLookupMultiSelectCtrl::constructWithQuery(element,warehouse,query);
super();

}

Thanks & Regards,

Ram.

  • Chaitanya raj Profile Picture
    Chaitanya raj 65 on at
    RE: Multiselect Custom Lookup Filter

    Hello Guys,

    Can anyone tell me how the ware house issue in this scenario is fixed, in the whole thread i didn't find the solution for that.

    Thanks

    Chaitanya

  • Verified answer
    Ram Kumar Profile Picture
    Ram Kumar 434 on at
    RE: Multiselect Custom Lookup Filter

    Yeah Martin,

    I have used the Queryrun object and then i have refreshed the queryrun object. It works fine.But i am facing some issues. When i am adding my sites in the site control it woks fine. Here the image for you reference. Here i have used syslookupmultiselectctrl class for multiselection lookup. The lookup method fires only first time of clicking the control.

    pastedimage1579845906375v1.png

    pastedimage1579846003052v2.png

    But when i unselect from the site control the warehouse control shows the last selected values, the value for the unselected site also shown in the warehouse control. Here is the image i have removed the No: 2 site but in the warehouse control shows for the warehouse values for the No: 2 site also. Do you have any suggestions.

    pastedimage1579846210041v3.png

    Regards,

    Ram.

  • Martin Dráb Profile Picture
    Martin Dráb 229,247 Most Valuable Professional on at
    RE: Multiselect Custom Lookup Filter

    Great!

    Can you please share the solution for others who have a similar problem and find this thread?

  • Ram Kumar Profile Picture
    Ram Kumar 434 on at
    RE: Multiselect Custom Lookup Filter

    Hi Martin,

    Yeah i have solved the issue. Thanks for your suggestions.

    Regards,

    Ram.

  • Martin Dráb Profile Picture
    Martin Dráb 229,247 Most Valuable Professional on at
    RE: Multiselect Custom Lookup Filter

    Can you share a simplified sample solution (e.g. as an .xpo)? If reproducing your problem takes less time, there will be a better chance that somebody looks on it.

  • Ram Kumar Profile Picture
    Ram Kumar 434 on at
    RE: Multiselect Custom Lookup Filter

    Hi Martin,

    Yeah , Shall you give the solution for this.

    Regards,

    Ram.

  • Ram Kumar Profile Picture
    Ram Kumar 434 on at
    RE: Multiselect Custom Lookup Filter

    Thanks Nicholaos anyway you had understood what my requirement finally . I hope may be i will find solution for this.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Multiselect Custom Lookup Filter

    I was able to reproduce this. It has nothing to do with the other lookup (Site).

    It seems that the lookup method of Warehouse is only executed one time: when the user clicks the lookup method for the first time. On further clicks the method is no longer executed, so perhaps it's cached somehow.

    I don't have ideas how to fix it, or if it's somehow caused by some detail in your code.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Multiselect Custom Lookup Filter

    The lookup method is expected to be executed every time when user clicks the lookup icon.

    If your Warehouse lookup method is not executed after changing values in Site field (and clicking the Warehouse lookup icon), then it doesn't matter what code you have in it. The problem can't be fixed by changing contents of that method.

    Do you happen to have any other code that would override the lookup method with something else? Or code that hides the original Warehouse field, and shows another Warehouse field instead?

  • Ram Kumar Profile Picture
    Ram Kumar 434 on at
    RE: Multiselect Custom Lookup Filter

    Hi Nicholaos,

    Here is my code i get the values for the lookup in the warehouse field from the site field control. So When i change the site field and then the warehouse fields lookup method will get hitted when i click the warehouse field . The value for the warehouse field will be filtered as per the value given in the site field. After changing value for the site field and then if i click the warehouse field , it doesn't hit the breakpoint in the lookup method. Sorry for the inconvenient description i have provided. Can you able to understand now. 

    Regards,

    Ram. 

    public void lookup()
    {
    SysLookupMultiSelectCtrl slmsc;
    Query query;
    QueryBuildDataSource qbds;
    List list;
    ListIterator itr;
    list = new List(Types::String);
    list = strSplit(Site.valueStr(),";");
    itr = new ListIterator(list);
    
    
    query = new Query();
    qbds = query.addDataSource(tableNum(InventLocation));
    qbds.fields().addField(fieldNum(InventLocation,InventLocationId));
    qbds.fields().addField(fieldNum(InventLocation,InventSiteId));
    
    
    if(Site.valueStr()!="")
    {
    while(itr.more())
    {
    qbds.addRange(fieldNum(InventLocation, inventsiteid)).value(itr.value());
    itr.next();
    }
    }
    
    else
    {
    throw error('Please choose Site');
    }
    slmsc = SysLookupMultiSelectCtrl::constructWithQuery(element,warehouse,query);
    super();
    
    }

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,888 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,247 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans