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
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é
you can loop the list and check if the text is already in the list or not.
Barong Bali wrote:
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.
You can use ListFilter or ListIndexOf with the desired condition and check if the result is empty or not.
Hello Henrique, José
Thank you, Let me try
if you have long list I suggest either to persist it in the database or use the HashTable.
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.
José
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?
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
Gopal Jite wrote:
mark the correct answer then..