3099
Views
7
Comments
Multiple search filters in an Aggregate.
Question

Hi everyone,

I am trying to create a simple reservation app containing multiple search criteria.I am using aggregate to filter the search results.Below is the screenshot of the web screen.I am using the filter criteria in one single filter in the aggregate,but it's not working as expected.

Search Criteria:
1. Use all filters(Name,Location,Date)

OR

2. Use any 1 of the filter(other 2 filters-empty)

OR

3. Use any 2 filters(3rd filter-empty)


And also,is there a way to hide the Result table on load of the web page?

Any help in this issue is appreciated.

Please find the attached OML file for reference.


Thank you,

Akshay V

ReservationApp.oml
2020-02-28 09-46-54
Eduardo Jauch

Hello Akshay

1. Filters

What you need is to use the "connect/disconnect" filter pattern (I made up the name :P lol)

Basically, what you need to do is to use a second condition, to each filter, that will turn the filter ON or OFF depending on a value.

So, if Name is a criteria for one filter, you can create it like this:

NameVariable = "" OR YourEntity.Name Like "%" + NameVariable + "%"

If NameVariable is empty (""), than that part of the expression will be TRUE for ALL lines in the result, and the filter will be turned OFF. If you put something there, than this part of the condition will be FALSE for all lines, and the line will enter or not depending on the result of the filter itself.

You just add your filters like this (with AND or separated filters).

 2. Table visibility

You can put the Table inside the TRUE branch of an IF and set the condition of the IF to be NOT GetYourEntity.Empty. 

This will make your table vivsible only if the source (your aggregate) is not empty.
On every search (if the button is set to Ajax Submit), you just use a data refresh in the aggregate and an Ajax Refresh in the IF (it must be named).

Hope this helps.

Cheers.

UserImage.jpg
Akshay V

Thank you, Eduardo Jauch and Pedro Costa. Both of the replies were helpful.

2022-07-12 16-41-57
Pedro Costa

Akshay V wrote:

Hi everyone,

I am trying to create a simple reservation app containing multiple search criteria.I am using aggregate to filter the search results.Below is the screenshot of the web screen.I am using the filter criteria in one single filter in the aggregate,but it's not working as expected.

Search Criteria:
1. Use all filters(Name,Location,Date)

OR

2. Use any 1 of the filter(other 2 filters-empty)

OR

3. Use any 2 filters(3rd filter-empty)


And also,is there a way to hide the Result table on load of the web page?

Any help in this issue is appreciated.

Please find the attached OML file for reference.


Thank you,

Akshay V

Hi,

Try using this in your aggregate filter

(Reservation.Name like "%" + Name + "%" or Name = "") and
(Reservation.LocationId = LocationId or LocationId = NullIdentifier()) and 
((Reservation.StartDate >= StartDate or StartDate = NullDate()) and (Reservation.EndDate <= EndDate or EndDate = NullDate()))


2023-05-18 05-39-48
Kiruthika Balasubramanian

Hi Pedro,

This helped for my scenario. 

Thank you,

Kiruthika

2017-12-13 08-27-28
Joey Moree

It might be a better (and more generic approach) to use advanced SQL instead, for instance:

You have a list with 2 attributes, FieldName and Value (value could be another list if you so choose)
Have a empty text variable where you write SQL, which you fill by iterating over your list (so you create a bit of SQL in this variable).

In the advanced SQL you add this variable to the query, make sure to set it to expand inline to make it able to run the text as SQL code.

This way adding a new field does not require you to change any other code.

UserImage.jpg
Akshay V

Thank you,Joey Moree. I'll try your approach.

2020-02-28 09-46-54
Eduardo Jauch

Akshay V wrote:

Thank you,Joey Moree. I'll try your approach.

I'll disagree.

Aggregates should be always used if possible.
There is simply no reason to use an SQL in the situation you asked, Akshay, as the possible criteria to search are known at design time.


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