Any time you loop through, or iterate, a collection of any type, there are some restrictions to consider. Inside the loop, you may change an individual member, but you may not change the collection itself.
For example, consider LineItems, a collection of LineItem entities in the InvoiceSample Rule Application.
As you loop through LineItems, examining each LineItem, you may change LineItem fields such as Quanity, but you may not remove the LineItem from the LineItems collection.
- Add Collection Member
- Clear Collection
- Copy Collection (copying into the collection)
- Remove Collection Member
- Sort Collection