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 :
Finance | Project Operations, Human Resources, ...
Answered

Multiselect Custom Lookup Filter

(0) ShareShare
ReportReport
Posted on by 454

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.

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Multiselect Custom Lookup Filter.

    Did you debug your code? Do you have all three values (1, 2, 12) in the list?

    If you write Site.valueStr() to infolog, do you see all three values?

  • Martin Dráb Profile Picture
    236,570 Most Valuable Professional on at
    RE: Multiselect Custom Lookup Filter.

    Surprisingly, another user has a thread with the same code. I would like to figure out what's going on and then discuss the issue just once. Discussing the same thing twice in parallel sounds like waste of resources to me.

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

    Hi Martin ,

    My Requirement is when i select the Sites in the Site Control ( Multiselect) , its related Warehouses also should be shown in the Warehouse control (Multiselect). At first i selected 1 and 12 sites , then it shows the 1 and 12 related warehouses in warehouse lookup control. After that when i selected 2 site , it doesn't  show the related warehouse for the 2nd site in the lookup.

    Thanks & Regards

    Ram.

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

    Hi Nikolaos,

    At first attempt when i select 1,2,12 at the same time the values for the warehouses in the warehouse lookup control shows correctly. After when i uncheck selection for the 2nd site , the lookup in the warehouse control shows again the values for 2nd site also, see the below image.

    pastedimage1579665543785v1.png

    pastedimage1579665604485v2.png

    pastedimage1579665734033v3.png

    Thanks & Regards,

    Ram.

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

    As your classmate / colleague / you other account, you pasted code without indenting, which makes it difficult to read. Let's fix it first, so we can read it. The trick is using Insert > Insert Code in the rich formatting view. (I already explained that in the other thread; that's an example of how duplicate thread lead to time waste).

    Here it is (I've also simplified it a bit):

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

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

    I have the same question as Nikolaos: what did you find when you debugged your code?

    If you didn't use debugger at all, it's not wonder that you don't know where things goes wrong in your code. It's time to do it now.

    Personally, I don't think that parsing the string is a good idea. Shouldn't you get the list of values from get() method of the SysLookupMultiSelectCtrl object used for sites?

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

    Hi Martin,

    When i selected sites 1,2,12. then i clicked the warehouse lookup control the debugger hits the lookup method. After it shows the corresponded warehouses in the warehouse lookup control. Then again i changed the site 1,2 only. But, now the debugger doesn't hit the breakpoint and the warehouse lookup control shows the previously selected sites only. So breakpoint was not hitting at the second time of modifying site lookup control. Can you able to understand what i explained now.

    Regards,

    Ram.

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

    The warehouse lookup should be hit everytime when you click the warehouse field's lookup icon. Did you click it in both cases?

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

    Hi Nicholaos,

    When i used multiselect lookup for site control only it works fine. But when i use both multiselect lookup for Site and Warehouse, it hasn't work. (See the image below)

    8233.perf1.png

    Here in the second image i used only site multiselect lookup control. It works fine ( shows the related warehouse for the site selected).

    per3.png

    Regards,

    Ram.

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

    So are you saying that when you click the lookup of the Warehouse filter, your breakpoint in the lookup method of that field is not being hit, if you have previously changed values in the Site filter?

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans