If I have an entity defined that has two columns
I have a server action defined called search. Search takes one input parameter, a structure with two attributes
I want to return all rows from the entity where the name and url match the passed structure attributes. However, if either field is empty, I do not want to use that field to filter the results.If my entity has two rows
The caller of my server action passes name = "Jim", Url="", I only want the Jim record returned. If they pass both as empty strings, I want to return both records.
What is the easiest way to accomplish this in Out systems? The number of structure attributes is not small, so would prefer a solution that uses Aggregates or SQL. I want a way if a structure attribute is not passed (empty), to remove that field from the WHERE clause.
hi you use expression with clause Like:
ContainerCollectionLocation.Location like % + Location_Input + %
For complex one and performance sake, I'd rather use Advance query.
regards
Hi @Gregory PiersonGood Day!!
Yes, you can use OS aggregate to perform this search, just go to filter and add these 2 filters.
Search.name = "" or YourEntityName.Name like "%"+Search.name+"%"
Search.url = "" or YourEntityName.Url like "%"+Search.url+"%"
So its check if anyone param is empty then no filter will be apply else it'll search by given input value.
I hope it'll help you.
ThanksDeep
Hi Gregory,
Add the below filter to the aggregate
(Search.name = "" and Search.url = "") or Entity.Name = Search.name or
Entity.Url = Search.url
Regards
Krishnanand Pathak
HI Gregory,Use this condition in you filter ,
(Entity.name like "%"+name(search name parameter)+"%" or name(search name parameter) =NullTextIdentifier() ) and (Entity.url like "%"+URL(search URL parameter) +"%" or URL(search URL parameter)=NullTextIdentifier() )regards venkatesaiya
Hi Gregory ,
Still can't able fix this issue? Deepsagar Dubey ,Krishnanand Pathak and Venkatesaiya made correct way. Please check and and do it. still having issue. please share the OML. we are going to help you.
Thanks,
Ramesh