Removing Pages Based on Condition from Page List in Pega
In real Pega projects, iterating over Page Lists is something you do almost daily — to read data, apply validations, or update records. However, the moment the requirement changes to removing pages from a Page List based on a condition, things often go wrong. I’ve seen many entry-level developers get stuck here. Let’s break down the clean and Pega-recommended way to handle this scenario. Understanding the Problem A Page List is an ordered collection of pages, for example: .Participants () .Transactions() Each page usually represents a business entity. Now imagine a requirement like: Remove participants whose Age < 18 Remove transactions where Amount = 0 This is where conditional removal becomes important. ❌ Common Mistake (Don’t Do This) Many developers try to remove pages while looping forward through the Page List. Example: Loop from index 1 → N Remove page at index 2 Index shifts → next page gets skipped This leads to: Skipped records Partial cleanup Hard-to-debug issues 👉 Ne...