Rest API filter records
Question

I have a DataAction with output parameter which gets filled with records from a REST API response. What I want is to filter all responses where a certain field value is partially equal to a certain value, out of the result set, so I can display the remaining records.

Should I use OnAfterResponse for this? Where and how do I enter the filter condition?


Hi Maurice,

You can use listfilter server side control  to filter the result set where you can metion the filter condition.

This control you can use in onafterresponse as well but imagine if you need another filter condition when you call the same api from different place so better keep the api generic and use the filter in the dataaction.

Best Regards

Devendra


Cant, you do the filtering from the method in the rest of API?

It is an aggregate you can use the like operator to see if is partially equal to a certain value.

 like "%something%",

Other than that, yes you should use an after fetch or you can use it inside of the data action and use regex to see if the value from the rest API matches a certain value.

Check this article about using data actions by @Kilian Hekhuis where it shows how to do the filter using an index.

https://medium.com/itnext/paginating-sorting-and-filtering-data-from-a-data-action-f5cb997fdc60?source=user_profile---------0-------------------------------

And also check this comment about regex to filter.

https://www.outsystems.com/forums/discussion/67668/its-possible-to-use-regex-search-in-an-aggregate-filter/#Post270321

Kind Regards,

M´árcio

Hi Maurice,

You can use listfilter server side control  to filter the result set where you can metion the filter condition.

This control you can use in onafterresponse as well but imagine if you need another filter condition when you call the same api from different place so better keep the api generic and use the filter in the dataaction.

Best Regards

Devendra


Hi,

Thanks for your response. I've been working on it, it turned out quite well. I use the List Filter in DataAction and it nicely filters out unwanted records from the API response.

The condition I have set is: Index(Picture, "UserImages") = -1

So every record where the Picture field contains the string "UserImages" is left out of the result set.

Thanks for your assistance!

Regards,

Maurice

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