4561
Views
10
Comments
Solved
How to verify item present in list or not?

Hi,

I have list of text and I am adding new text item into list but here I want to add item only if it's not already present in list.


Thanks in advance

2020-03-05 14-29-02
José Costa
Solution

Hi Gopal,

You can also use the ListIndexOf Action (from System module). It will give you the index of the first that it finds, or -1 if it does not find any.

Cheers,

José

2025-01-09 14-56-57
IQ78

you can loop the list and check if the text is already in the list or not.

2020-07-16 17-08-27
user

Barong Bali wrote:

you can loop the list and check if the text is already in the list or not.

Thanks Borong but It will take more time, 

If my list already have 1000 record and I am adding new 100 record then it will take lot of time to execute, If you have another option please share.

2017-07-05 22-17-18
Henrique Batista
Staff

Hi Gopal,

You can use ListFilter or ListIndexOf with the desired condition and check if the result is empty or not.

Cheers,

2020-03-05 14-29-02
José Costa
Solution

Hi Gopal,

You can also use the ListIndexOf Action (from System module). It will give you the index of the first that it finds, or -1 if it does not find any.

Cheers,

José

2020-07-16 17-08-27
user

Hello Henrique, José

Thank you, Let me try


2016-04-21 20-09-55
J.
 
MVP

if you have long list I suggest either to persist it in the database or use the HashTable.

2020-03-05 14-29-02
José Costa

Hi Gopal,

If you are starting your list from scratch and your list is of type Text maybe your best option is to use an HashTable:

https://www.outsystems.com/forge/21/

This is a more efficient solution to large number of records when searching for an item present in a List.

Cheers,

José 

2020-07-16 17-08-27
user

Hi,

ListIndexOf() requires two values, 1) list  2)condition .

for example

My list is "ColorList" and I have text "Blue" which I want to add

I pass ColorList to the list property but what will be the condition? 



2020-07-16 17-08-27
user

Thanks J & Jose,

I am adding it into my knowledge bank :)

Actually my list isn't that much big. ListIndexOf() solved my problem.

Thank you Henrique & Jose



2025-01-09 14-56-57
IQ78

Gopal Jite wrote:

Thanks J & Jose,

I am adding it into my knowledge bank :)

Actually my list isn't that much big. ListIndexOf() solved my problem.

Thank you Henrique & Jose




mark the correct answer then..

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