how to improve by using ListIndexOf to verify item exist in list or not

Hi All,

How can I improve my code by using ListIndexOf action to check if the item exist in a list? Currently I'm using For Each Loop and IF to check if the movie title entered by user is exist in database.

Firstly, I fetch the data from aggregate and stored in a list 'MovieList', then I initialize the Index = 0 as Start Iteration and List Length = MovieList.Length as Maximum Iteration. Then, I using IF as my condition 

MovieList[Index].Title = MovieTable.List.Current.Movie.Title

to check if the Movie Title entered by user is match with the records in list. If yes, it will prompt an error message to notify user and increment for Index, and continue to search in list until end. If no, will also increment for index until end..

Below is my code action flow:


Solution

Hi Gwen,

The below mentioned filter condition clearly confirms that you are checking a singe MovieTitle Label's existence in a list of Movie Labels

MovieList[Index].Title = MovieTable.List.Current.Movie.Title


I can state two solution (i.e. Action flow) for required validation/Movie Title label existence check

Hope this helps you!


Regards,

Benjith Sam

Solution

Hi Gwen,


You can use ListFilter to check title exists in list or not. you can verify multiple cases with ListFilter to filter record. After check the condition ListFilter will give you filtered list according to your condition and you can notify to users.  


   

Hi Gwen,

if you want to check if something already exists in a database, please go with option 2 offered by Benjit, that's what databases are for, they are much better and faster at finding an answer to your question than you could ever by with your own code.

As you are already going to the database anyway to retrieve the list, there is no reason to do it any other way.

Dorine

Benjith Sam wrote:

Hi Gwen,

The below mentioned filter condition clearly confirms that you are checking a singe MovieTitle Label's existence in a list of Movie Labels

MovieList[Index].Title = MovieTable.List.Current.Movie.Title


I can state two solution (i.e. Action flow) for required validation/Movie Title label existence check

Hope this helps you!


Regards,

Benjith Sam

 Hi Benjith,
Thanks for your help! I will go for the solution number 2.

Hi All,
Thank you all for the suggestion !

Many thanks.

 

Gwen wrote:

Hi Benjith,
Thanks for your help! I will go for the solution number 2.

Hi All,
Thank you all for the suggestion !

Many thanks.

You are welcome, Gwen :)

I'm glad that it helped you :)


Regards,

Benjith Sam