Clear method in Remove from Collection Activity

In the latest UiPath Studio Community Edition, the Remove from Collection / Clear() method does not fully clear the collection, and elements remain available. Has anyone else experienced this issue?

Hi @Balachandrasekhar_C ,
This is not a Studio bug. Clear or Remove From Collection only clears the in-memory instance. If items still exist, the collection is being reassigned or repopulated later, or you are clearing a different instance due to scope or arguments. Make sure the same collection reference is used and not reloaded from Config or another variable.

Thanks & Happy Automation

Hi @Balachandrasekhar_C

Please try this approach
Instead of using Remove from Collection / Clear(), reinitialize the collection variable. This guarantees it is fully reset and avoids unexpected re-population.
myList = New List(Of T)
Or set it to myList = Nothing
Also ensure the Clear is not inside a loop where items are added again, and verify with myList.Count immediately after clearing.

Cheers

Seems this is to be a bug, you can downgrade to stable versions, it works fine.

2 Likes

I’m passing same collection var name as a input.

Working normally when we use expressions and concern is about this activity in new version.

Pass the collection as an In/Out argument or Out argument. Then call Clear() on it. This way the same collection instance is modified and the changes are reflected back in the parent workflow.

Can you share the screenshot of this error

Instead of using Remove from Collection / Clear Collection, re-initialize the collection variable. This guarantees the list is fully reset and avoids the unexpected re-population seen in newer UiPath versions.
myList = New List(Of T)
’ or
myList = Nothing
This works reliably when done via Assign expressions.

Also ensure the Clear activity is not inside a loop where items may be added again, and always validate using myList.Count immediately after clearing.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.