Is it possible to iterate List without using For Each activity?


#1

I am trying to create a flowchart that each item in a list will go through a flow decision activity.
any advice will be greatly appreciated.

Thanks!


#2

@albert.yango what you need to check in the decision activity?


#3

@Madhavi I will check if a string contains “.pdf”. I can make this work using for each and if activity but i need to use flow decision for better interpretation of the whole process.


#4

@albert.yango if you just want to check whether “.pdf” exists in any of the list items, you can use below line in decision statement-
lstFiles.Any(function(x) x.Contains(".pdf"))
where lstFiles is the List of files

Please let me know if your requirement is different.


#5

@Madhavi I want to check whether the .pdf string is present in each item in a list.
Example: If the first item does not contain .pdf, it will print “item does not contain .pdf”
If the second item contains .pdf, it will print “item contains .pdf”. This will loop until all the items in a list is checked.


#6

@albert.yango
instead of Any use All in the query. This will check whether all items in the list have the value “,pdf”
lstFiles.All(function(x) x.Contains(".pdf"))


#7

hi @albert.yango

If you don’t want to use foreach, you can access all the items of the list one by one by passing the item number i.e. listOfFiles(counter). Please note that in this case you will have to keep incrementing the counter till all the items have been iterated.

Let me know if this helps!


#8

@Prakshi_Tyagi No offense. You could use list with index. But to increment the index, you still need to add a loop.


#9

Hi @Prakshi_Tyagi I have followed your instruction and it worked! Thanks