Sean Salaz (SALAZONE)
Senior System Architect, Pega Academy
SALAZONE Member since 2006 46 posts
Posted: February 4, 2016
Last activity: May 20, 2016
Posted: 4 Feb 2016 15:01 EST
Last activity: 20 May 2016 5:59 EDT

Ensuring uniqueness in a PageList

We recently had a requirement to ensure that a specific value was not repeated in a PageList. The function to use was countInPageList(LookFor, LookAt, PageList) however our situation was more complex because we didn't know what the value of LookFor was going to be in advance.

The use case was, "Ensure a course name is not used more than once when defining a lesson". Trying to hard code course names in advance was not a viable solution since 1) there were so many already 2) more will be added in the future. My approach was to create a local variable to hold the value of the .pyID of the current course in the PageList to be evaluated. This value was then used in the countInPageList call as: @(Pega-RULES:Utilities).countInPageList(local.pyID, ".pyID", .Courses)
Where local.pyID is the local variable holding the .pyID of the course to be evaluated, ".pyID" is the pyID property in the PageList, and .Courses is the name of the PageList.
So if the .Courses PageList consisted of :
Courses(1).pyID = C-191
Courses(2).pyID = C-192
Courses(3).pyID = C-191
Then the first time through, local.pyID would be assigned C-191. countInPageList would then traverse the PageList looking for "C-191" in the .pyID property within the .Courses PageList. 
countInPageList returns an integer which identifies how many times it found the "LookFor" variable. I assigned this to another local variable, local.Count which was evaluated in a Jump statement. If local.Count > 1, it meant the local.pyID was found in the PageList more than once which is incorrect so the activity would advance to an error handling step. In the example above local.Count would be = 2 so the activity would jump to said step.


Data Integration Java and Activities
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Discussion, please write a new Discussion.