DropdownSearch to filter Aggregate
Question

Hello,

I am trying to use a DropdownSearch to filter an aggregate. However, this is not working, as I believe I am not saving the selected item correctly.

These are my DropdownSearch parameters:

In my DropdownSearchLine client action, all I have is a Refresh for my aggregate where I use the following filter:

InterfaceValues.location like "%" + SelectedLine2.Current.Value + "%"

I used console.log to log SelectedLine2.Current.Value and it seems to be empty.

Whenever I select a value from my dropdown, nothing happens on my aggregate.

I searched a bit, but I am new to OutSystems, so any help would be appreciated. Thank you very much.


mvp_badge
MVP

Hi CB,

Given you ise SelectLine2.Current, SelectedLine2 is a List instead of a single record. Why's that? I wouldn't expect a List to be used there.

Good point, I changed the data type to text. Thank you.

Set a local variable that will hold the value you want to search by. Then, in your aggregate, set your filter to be based on the local variable you set in the drop down. Finally, set an "OnChange" event for your drop-down and use that action (OnChange) to refresh the aggregate. This will allow you to filter by the dropdown.
Also, I would change your filter query to be more like:

Trim(Aggregate value you want to filter by) = LocalVariable pulled from Dropdown

Since you are using a dropdown the values should be exact making the "like" call unnecessary.

Thank you. All of that seems to make sense, but somehow is still not working.

This is my DropdownSearch:


This is my DropdownSearchLine Client Action (the OnChanged event):


And these are my aggregate filters (I tried both with and without trim):

But this is what I get (console shows that SelectedLine2 local parameter is empty):

SelectedLine2 is the local parameter, and SelectedLine is the input parameter in the dropdown that is associated with SelectedLine2.

mvp_badge
MVP

Hi CB,

Apologies for not looking better into your problem, I was not paying attention to what you did exactly.

Following these instructions, I made a small example myself. First, something to understand is that the DropdownSearch fires an Event whenever the user selects an option, for which you specify a handler:

If you choose the "New Client Action" option from the menu, Service Studio automatically creates the right Screen Action (called "DropdownSearchOnSelect") with the right input parameter (called SelectedItem). The OnSelect Event has a single parameter, "SelectedItem", that is the input for the handler (hence the "SelectedItem" to "SelectedItem" mapping in the Event Handler - note that the left-most SelectedItem is the input parameter to the OnSelect handler and the right-most SelectedItem is the Event's parameter). Inside your OnSelect handler Action the input parameter (here SelectedItem) contains the selected value.

Looking at your code, we can see that your DowndownSearchLine action (which is a bit obscurely named, the default "DropdownSearchOnSelect" better describes what it's for) has a SelectedLine input, but instead of putting the Event's parameter "SelectedLine" in it, you input the Local Variable SelectedLine2, which of course doesn't contain anything at that stage.

So what you need to do is pass SelectedLine (the Event's Parameter) to the SelectedLine input of the handler, instead of the Local Variable SelectedLine2, and it should work. I don't think you need that Local Variable at all.


Okay, I understand but I can't pass SelectedLine as the input of the handler. Is there anything that I am missing for this to work?

I get the "Can't identify 'SelectedLine' element in expression." error message.

Btw, I have managed to do this with a normal Dropdown tool, instead of the DropdownSearch, but I am stubborn and a DropdownSearch would be the preferred tool :-)

mvp_badge
MVP

Hi CB,

I checked, and the DropdownSearch On Select event also has a SelectedItem as input, so it should work accordingly:



I think the issue you are running into is that you have many filter criteria. Specifically number 4 seems to be unnecessary if you get the dropdown menu set correctly.

DropDownSearch.oml

mvp_badge
MVP

The issue he's running into is that the variable that he expected to hold the selected value was a local variable that is empty (which wasn't the problem, see my post). He also told a few times the value was empty. So I'm not sure why you think it's the filter criteria causing the problem.

Filter #4 is not the issue, I have tried both with and without. 

This filter #4 is for a search input, as I am trying to have both options available: search in the table via dropdown and search in the table via written input.

Thank you both.

Okay, so number 4 is not the issue. In including the Pictures and the OML it should be easier to see where the Local Variable is being assigned. When the Dropdown selects a new value, that value is passed to the local variable. Also, note that I'm using a standard dropdown and not a dropdown search. 

My thought on the #4 issue is that there are a bunch of filters for the data and this could be a confounding variable in the execution of logic. My personal process is to keep my logical flows as simple as possible. 

mvp_badge
MVP

I agree on keeping the logic simple, but if you are trouble shooting, you shouldn't do refactoring ;).

mvp_badge
MVP

"When the Dropdown selects a new value, that value is passed to the local variable " - no it is not. It is sent as an input parameter of the event handler.

If you are using a dropdown and set the variable as the local variable, you do not need to worry about the input parameter of the event handler. The action will occur without intervention. So, yes, when the dropdown selects a new value, that value is assigned to the local variable. 

mvp_badge
MVP

I really don't understand what you mean. I admit I'm not too familiar with Reactive, but from what I've seen, there's no way to specify a local variable to receive the selected value. When an option is selected, the event is fired, supplying the selected value as parameter to the event handler. That's the only place, as far as I can see, that the selection is available.

Feel free to check on the OML I provided, but I'll also include some shots in this message to show the flow I'm talking about.

The dropdownonchange only refreshes the aggregate I'm using as a search database. The dropdown widget stores the current selection reactively in the specified variable and the aggregate uses this variable to filter results. The refresh action just updates the display on the page.  



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.