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.
In below activity you can see use of IsInPageList as sample,
@IsInPageList("Customer", ".pxPartyRole", .pyWorkParty )
If you have page structure like --
You have to use the function like below :
@IsInPageList("String what to compare", ".TestProperty" , pxRequestor.OperatorID.SomePageList)
Where as IndexInPageList cab used as below,
first parameter is value of the property--string,
second parameter is property reference--string,
and the third parameter is ClipboardProperty.