Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

How to delete elements from List and Group properties in a Java step

Updated on September 13, 2021


Often you need to delete selected items from a Page List property based on conditional code for each item. This article describes useful PublicAPI methods you can call within a Java step.



Suggested Approach

The For Each step generates Java using the Iterator object.

You cannot delete items from the Iterator object while it is running. To delete items, your code must iterate through the elements manually in Java, as illustrated below.

After you delete an element from a list, the next call to the PublicAPI method getStringValue(i) or getPageValue(i) (for Value List and Page List properties, respectively) will return the next element. Note also that the size() will change as you delete items.

ClipboardProperty list = myStepPage.getProperty(".pxResults");
for (int i = list.size() ; i > 0; i--)
// if PageList, then you can get the page and perhaps
// check a value, this can't be used if "list" is a ValueList
ClipboardPage row = list.getPageValue(i);
// test if you want to delete
if (delete)

To iterate through the elements of a Page Group property without using an iterator, you need to reference the elements by name; you cannot access elements by number. To get the keys, you can loop through initially and put them into an array:

ClipboardProperty list = tools.findPage("aPage").getProperty(".aPageGroup");
java.util.Iterator itr = list.iterator();
//arrayList of elements that have to be removed.
java.util.ArrayList removeList = new java.util.ArrayList();
ClipboardProperty row = (ClipboardProperty) ;
if (OkToDelete ) // OkToDelete refers to some condition that checks
if it's ok to delete the current element
// add the subscript of the group to the arrayList
// of elements that have to be removed
int size = removeList.size();
for (int i = 0; i < size; i++)



Pega Platform 7.1.1 - 8.3.1 System Architect Low-Code App Development Data Integration

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us