How to Work with Lists in a Data Transform: Helper Functions
Lists are powerful data structures in Pega that allow you to store and manipulate collections of values.
This guide provides a comprehensive overview of some functions that can be used to work with lists in data transforms.
Functions for Value Lists and Page Lists
When working with Pega applications, you'll often need to manipulate Value Lists (simple collections of values) and Page Lists (structured data collections). The following functions will help you perform common operations on these lists.
Checking List Contents.
These functions help you verify if specific values exist within your lists:
IsInPropertyList - Checks if a specific value exists in a property list
- Syntax: @IsInPropertyList(value, list)
- Returns: True if the value is found, false otherwise
- Example: @IsInPropertyList("Value", .MyList) = true
- Usage: @IsInPropertyList("Jack Bauer", .NamesList)
IsInPageList - Checks if a specific value exists in a property within a page list
- Syntax: @IsInPageList("Value", "Property", PageList)
- Returns: True if the value is found, false otherwise
- Example: @IsInPageList("value", "property", PageList) == true
- Usage: @IsInPageList("Tony Almeida", "pyLabel", .OperatorList)
IsPageListEmpty - Checks if a specific property in a list is empty
- Syntax: @Utilities.IsPageListEmpty(tools, aPageListRef, aPropName)
- Returns: True if the property is empty across all entries, false otherwise
- Example: @Utilities.IsPageListEmpty(tools, ".OperatorList", "pyLabel")
PropertyListContains - Function to check if a value exists in a value list
- Syntax: @Default.PropertyListContains(strListReference, strScalarValue, insActivity)
- Usage: @PropertyListContains(".NamesList", "Jack Bauer", this)
List Size and Properties
These functions help you determine the size of your lists:
LengthOfPageList - Returns the number of items in a list
- Syntax: @LengthOfPageList(pageList)
- Works for: Both value lists and page lists
- Usage for Value List: @LengthOfPageList(.NamesList)
- Usage for Page List: @LengthOfPageList(.OperatorList)
SizeOfPropertyList - Returns the number of elements in a list
- Syntax: @SizeOfPropertyList(list)
- Works for: Both value lists and page lists
- Usage for Value List: @SizeOfPropertyList(.NamesList)
- Usage for Page List: @SizeOfPropertyList(.OperatorList)
countInPageList - Returns the number of items in the property list that match criteria
- Syntax: @countInPageList(value, property, pageList)
- Usage: @countInPageList("UCT Field Agent", "pyPosition", .OperatorList)
Working with Lists
These functions help you manipulate and transform your lists:
SortPageList - Sorts a page list based on a specified property
- Syntax: @pxSortPageList(pageList, property, [ascending])
- Parameters: pageList (the list to sort), property (the property to sort by), ascending (optional, direction of sort)
- Usage: @pxSortPageList(.OperatorList, "pyLabel", "ascending")
RemoveDuplicatesFromPagelist - Removes duplicate entries from a page list
- Syntax: @Utilities.pyRemoveDuplicatesFromPagelist(Primary, PageListName, DuplicateCheckProperties)
- Usage: @Utilities.pyRemoveDuplicatesFromPagelist(Primary, ".OperatorList", "pyPosition")
pxJoin - Joins property values with a separator
- Syntax: @NLPUtility.pxJoin(property, separator, pageList)
- Usage: @NLPUtility.pxJoin("pyUserIdentifier", ", ", .OperatorList)
References:
- https://docs.pega.com/bundle/platform-241/page/platform/data-integratio…
- https://docs.pega.com/bundle/glossary/page/glossary/p/glossary-p.html