75
Views
12
Comments
Solved
Executing search within a table based on the selected Attribute name
Application Type
Reactive
Service Studio Version
11.54.47 (Build 63164)

Hi,

I'm new to OutSystems and this is the first time I'm posting here so please excuse me if I don't explain my issues very well.


I am making a form to log dispatched items and wanted to add an ability for the users to be able to see a few of the last entries and also to search through older entries.
Ideally, I want them to be able to search based on the attribute they can select from the dropdown menu I've added.
I've managed to get the dropdown to show the names of all the relevant attributes and I know how to set up the search bar but I've been trying for hours now to link these two together so that a user can select the attribute they want to search through and search for the keyword they input into the search box.


tl:dr How to set up search so that the keyword is searched within the selected Attribute, e.g. pick "Accessories" and search for "www" 

DispatchTracking.oml
2024-02-26 11-18-24
Luís Agostinho
Staff
Solution

Hi Marcin!

I'm assuming the list that populates that dropdown has an Id and Label.
You can a boolean attribute (IsSearchable) in that list which is only true if it is indeed selected in the dropdown.
Then an expression in the aggregate for each attribute:

If(DropdownListAccessories.IsSearchable,DispatchTrackingDatabase.List.Current.DispatchTracking.Accessories like "%" + SearchKeyword + "%",True) or
If(DropdownListStaffName .IsSearchable,DispatchTrackingDatabase.List.Current.DispatchTracking.StaffName like "%" + SearchKeyword + "%",True) or (...)


Hope this helps!

UserImage.jpg
Marcin Hibner

Hi Luis,
As Mithun mentioned, the way the dropdown was set up originally wouldn't work as it was only writing the names of the attributes, which I then tried appending within the function.

You both have pointed out that the dropdown needs to grab the Id and Label instead, which I will try to remember for the future.
I'm sure your function would achieve the same result but I've already tested Mithuns implementation and it works so I will stick with that.

Thank you for your help.

2020-11-30 04-40-12
Mithun Rathod
Solution

Considering your scenario. I have made changes. I have added a static entity to get column names in the drop-down. Now based on a selection from the drop-down and the search key word, the result is getting fetched. 
Please find attached oml file.
If you don't want to add static entity, then create a one server action and pass the selected drop-down value's id, based on that gets the name and return it. Use the same name in the filter instead of --> SearchBy variable

DispatchTracking.oml
2025-01-09 14-56-57
IQ78

hi, use condition in the aggregate. something like this:

ContainerCollectionLocation.Location like '%' + Location_Input + '%' 

UserImage.jpg
Marcin Hibner

Hi ibox,

Thank you for your quick reply.

I've tried doing what you've suggested but it didn't work. The way that the dropdown is setup might be incorrect as I've got it to write into a LocalVariable called "SearchBy" and from what I understand it only writes the name of the attribute, e.g. "Courier", and not the full location reference, so what I tried doing is adding the "SearchBy" var to the location designation in different ways, like shown below, but I'm struggling to figure out how to do it

Below is an example of what happens when I use your method


2020-11-30 04-40-12
Mithun Rathod

Hi Marchin,

You need to add filter like this --> DispatchTracking.Accessories like "%" + SearchKeyword + "%"

The filter below you have added that is incorrect.

DispatchTrackingDatabase.List.Current.DispatchTracking.Accessories like "%" + SearchKeyword + "%"

Please find attached oml. It is working fine now.

Also, if you want to search irrespect of the any field like accessories, then you can add or condition in the filter.

eg: DispatchTracking.Accessories like "%" + SearchKeyword + "%" or DispatchTracking.StaffName like "%" + SearchKeyword + "%"

DispatchTracking.oml
UserImage.jpg
Marcin Hibner

Hi Mithun,
Thank you for your help, it solves part of the problem but I still can't figure out how to get the attribute that you search in to change dynamically, based on the input in the dropdown menu.
EDIT: I've tried your method of searching through multiple attributes and if I don't find a way to search through a selected attribute I will use that method, thank you.


2020-11-30 04-40-12
Mithun Rathod
Solution

Considering your scenario. I have made changes. I have added a static entity to get column names in the drop-down. Now based on a selection from the drop-down and the search key word, the result is getting fetched. 
Please find attached oml file.
If you don't want to add static entity, then create a one server action and pass the selected drop-down value's id, based on that gets the name and return it. Use the same name in the filter instead of --> SearchBy variable

DispatchTracking.oml
UserImage.jpg
Marcin Hibner

Hi Mithun,

That does exactly what I wanted. thank you.

I've tried doing this with nested if statements but I think I've used the wrong syntax. 
Also, I see that, even if set up the function correctly, It wouldn't work with how I have set up the dropdown (which I suspected before) so thank you for showing me the correct way to achieve this.

2020-11-30 04-40-12
Mithun Rathod

Hi Marcin,

I am glad that I could able to help you.

Happy learning 

UserImage.jpg
Marcin Hibner

Hi Mithun,
Do you know why the Courier input box pre-fills with "COUNTER" in this new version?
I don't see where the default value might coming from.

2020-11-30 04-40-12
Mithun Rathod

Hi Marchin, Are you talking about pre-filled form. Please refer below screen shot

if yes, Because input box values is getting hold by the aggregate attribute e.g DispatchTrackingDatabase.List.Current.DispatchTracking.Courier. Hence we are getting pre-filled values.


UserImage.jpg
Marcin Hibner

Hi Mithun,

I'm talking about the two fields shown in the screenshot.

When the form is refreshed, the "Courier" field contains "COUNTER" and the "Stock" field contains "0"

It's not a huge deal but ideally, I would like all the fields to be empty.
Seems like something is setting these values after the "SaveOnClick" logic is completed as there is a "RefreshData" logic module that I'm using to reset the form after a successful submission.

2024-02-26 11-18-24
Luís Agostinho
Staff
Solution

Hi Marcin!

I'm assuming the list that populates that dropdown has an Id and Label.
You can a boolean attribute (IsSearchable) in that list which is only true if it is indeed selected in the dropdown.
Then an expression in the aggregate for each attribute:

If(DropdownListAccessories.IsSearchable,DispatchTrackingDatabase.List.Current.DispatchTracking.Accessories like "%" + SearchKeyword + "%",True) or
If(DropdownListStaffName .IsSearchable,DispatchTrackingDatabase.List.Current.DispatchTracking.StaffName like "%" + SearchKeyword + "%",True) or (...)


Hope this helps!

UserImage.jpg
Marcin Hibner

Hi Luis,
As Mithun mentioned, the way the dropdown was set up originally wouldn't work as it was only writing the names of the attributes, which I then tried appending within the function.

You both have pointed out that the dropdown needs to grab the Id and Label instead, which I will try to remember for the future.
I'm sure your function would achieve the same result but I've already tested Mithuns implementation and it works so I will stick with that.

Thank you for your help.

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