Posted: 15 Jun 2020 21:35 EDT Last activity: 16 Jun 2020 19:32 EDT
Looping through pyAttachments and triggering a When Condition
I am looping through attachments on the pyWorkPage which have been created/referenced via a Datapage.
My requirement is to find the index of pyCategoryName when the pyCategoryName equals "Comatose"
Can some show me what I am doing wrong in the activity below and specify the correct syntax.
When I run the above code, PEGA does not fail.
My Param.testing in step 4. shows the correct length of
'pyAttachments [Refers to D_AttachmentList_3981pz.pxResults]'
My Param.test that I set to zero in Step 2 is still zero which makes me think that Step 3 is not executing at all as it is not of pxResults Type.
How can I loop through 'pyAttachments [Refers to D_AttachmentList_3981pz.pxResults]' under pyWorkPage and will my WHEN rule in 3.2 fire or do I need to reference it using <CURRENT>. In my pages and classes I have declared TempPage to be the pyWorkPage Class and pyAttachments as Link-Attachment.
Your 'pyAttachments [Refers to D_AttachmentList_3981pz.pxResults]' needs to be on Step 3 and NOT TempPage.pyAttachments. Your screen shows that 'pyAttachments is referring to D_AttachmentList_3981pz.pxResults. Is there a way to reference the D_AttachmentList_3981pz.pxResults directly instead of using the reference?
The activity looks fine. You can probably make sure that the page context for that activity loop is right(what your primary page is?) and the looping is being done on embedded pages or whatever makes sense in your scenario.
I understand your requirement is to fetch the COUNT of pagelist records which have categoryName as camatose. IndexInPageListWhen and IndexInPagelist only return the first index for which the WHEN condition becomes true. So, you'll probably have to loop through to get the count.
I just reproduced a similar scenario with pagelist referring a datapage and a loop on that pagelist in an activity works completely fine.
Thanks for all your suggestions. Shruthi solved my issue by showing the screenshot of the syntax alongside the clipboard.
My difficulty was the DataPage I was using was itself a reference under the pyWorkPage of a class that was again being referenced inside a QueueProcessor but the logic is very much like Shruthi's screen shot where she is able to call .PagelistreferringDP on the Step Page.
As you can see below, my referenced DataPage is similar to Shruthi's screen shot.
I solved it by using the following declarations in my Pages & Classes TAB.
In my activity, I call as shown below where TempPage.pyAttachments is the step page and since it of type Code-Pega-List, I can loop through.
Since TempPage.pyAttachments.pxResults is of Type Link-Attachments, my WHEN condition also fires correctly when i use a "." in the WHEN condition is used as .pyCategoryName
IndexInPageList does not work for me in this scenario as I need to loop through the complete list of attachments before doing some other processing and I was not even able to loop in the first place.
As TempPage.pyAttachments was NOT declared as Code-Pega-List in my Pages and Classes and PEGA processing just skips over that particular step if it does not think the step is right, it is difficult to debug such errors especially when PEGA does not throw an error.
Thanks Shruthi for taking the time to first understand the issue, recreating the scenario by first creating your activity, then creating a referenced DataPage and then testing the functionality before finally pasting the screen shots with the Clipboard and Activity right next to each other, making it so easy for an onlooker to easily understand your logic.