2425
Views
7
Comments
Solved
Find the given Text exists in the List of Text
Question

Hi 

I have a condition like i need to search for a Text which exists in a list of Text how can i do this on outsystems?

We have a method in Java like list.contains(string) is their any similar way in this?

2023-02-03 11-00-49
Ruben Bernardo
Solution

You can use System.ListAny (Determines if any of the elements in the list satisfies the given condition). 

The condition is up to you. Either you check if a string matches the current element Table.Field = String or you search if a particular field contains the given string Index(Table.Field,String) <> -1.

2024-02-16 07-43-18
Amit Verma

laxmiprasanna b wrote:

Hi 

I have a condition like i need to search for a Text which exists in a list of Text how can i do this on outsystems?

We have a method in Java like list.contains(string) is their any similar way in this?

Hi laxmiprasanna,

https://success.outsystems.com/Documentation/Development_FAQs/How_to_find_out_if_a_string_is_contained_in_another_string


https://www.outsystems.com/forums/discussion/47829/search-on-list-of-text/


Thanks,

Amit


2023-02-03 11-00-49
Ruben Bernardo
Solution

You can use System.ListAny (Determines if any of the elements in the list satisfies the given condition). 

The condition is up to you. Either you check if a string matches the current element Table.Field = String or you search if a particular field contains the given string Index(Table.Field,String) <> -1.

2021-10-26 09-17-56
João Delgado


I think Ruben's suggestion is a good approach for you problem. After using it, you just need to verify if the ListAny output is True or False.


Best Regards,

João Delgado

UserImage.jpg
Thanigaiarasu Arumugam

Hi,

Why don't you use ListFilter.

In outsystem we have ListFilter in under system server action. There are 2 inputs for that, one for list and another one for condition(listtextattr="your text"). 

Best Regards,

Thanigai

2018-11-07 11-35-05
Filipe Alves

Hi,

Thanigai is right. ListFilter is an excellent action for your case.

Miguel Melo gives this example

"I filtered a Products list (containing 100k products) around 200 times using both approaches and the ListFilter action consistently outperformed the iterator by a factor of 2.5x."

https://medium.com/productleague/list-we-forget-387fbd5173d4

https://success.outsystems.com/Documentation/11/Reference/OutSystems_APIs/System_Actions#ListFilter

Best Regards,

Filipe Alves

2023-02-03 11-00-49
Ruben Bernardo

If the objective it is just to evaluate if a given string exists in a list of strings, there's no need to use ListFilter because (1) you'll generate a list that has no use and (2) if the condition evaluates to true, the output of ListFilter is the given string. 

ListAll or ListAny are the best approaches when you just want to check if a list satisfies a given condition.

UserImage.jpg
Thanigaiarasu Arumugam

Hi Ruben Bernardo,

We can utilize that. if you expect the output is True or False, then you can achieve it by this. 

In my case List Filter gives output as list, if the list is empty the string not exist if the list is greater than 0 then its exist.

But this is good for limited length of list. But Filipe Alves's case, he got good performance, so no problem i think.

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