Discussion

How to access index of pagelist where the sub-pages are being deleted during processing

Scenario is as given below:

1. I have an activity A which has a Code-Pega-List called Page containing sub-pages as Page.pxResults(). Say the pagelist has 10 sub-pages.
2. I call activity B from activity A and loop through Page.pxResults() on the step page for each iteration of activity B
3. During the processing of activity B, I am conditionally deleting the current sub-page within scope - hence I may delete Page.pxResults(1) if some conditions are satisfied. In this case the earlier  Page.pxResults(2) automatically becomes  Page.pxResults(1) and so on.

The issue is that once I delete Page.pxResults(1) and PEGA automatically makes Page.pxResults(2) as Page.pxResults(1) and the next iteration begins, PEGA still refers to Page.pxResults(2) which was earlier Page.pxResults(3). The issue as you can observe is that PEGA has skipped the old Page.pxResults(2) which after page-delete is Page.pxResults(1).

I have also noticed that param.pyForEachCount continues to increase (which is fine) but I could not find any method/param which would exclusively refer to the index of the current iteration scope.

Has anybody else encountered this issue? My whole issue is around the fact that there is no way I can refer to the current scope of iteration (as param.pyForEachCount keeps increasing even if there is a sub-page delete and PEGA automatically re-indexes the sub-pages to start from 1).

I know that programatically this is not a challenge as there are other ways to keep a handle of the current context of iteration but I was hoping there would be a param/method which would just give us the current context of iteration.

 

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

Pega
March 17, 2015 - 9:24pm

Having exactly the same issue here and trying to figure out to how to work around this. Any updates on this post?

March 18, 2015 - 1:59am

Hi Toshihide,

There seems to be no direct way of doing this so I did it programatically. Following is that I did:

1. Iterate through all the pages of the pagelist Page.pxResults() and based on your conditions set a property DeleteMe to True/False. What we are basically doing here is that instead of deleting the pages on the fly during the looping we are setting a flag on the pages we want to delete. We are doing this because we do not want to disturb the internal param.pyForEachCount pointer as discussed above.

2. ONLY WHEN THE ABOVE LOOPING IS COMPLETE, in the next step of the activity you can loop through Page.pxResults(). Use Obj-Filter with the when conditon DeleteMe=True to knock out the pages that were not required. Now you will only be left with pages which are required.

Let me know if there is anything you want to discuss further.

Pega
March 18, 2015 - 7:03pm

Just to add to SaurabhFS, you could also use a For Loop in the activity and subtract one from the Stop and Increment whenever you remove a page.  You will have to set the Stop and Increment parameters manually.

Pega
March 18, 2015 - 7:03pm

Just to add to SaurabhFS, you could also use a For Loop in the activity and subtract one from the Stop and Increment whenever you remove a page.  You will have to set the Stop and Increment parameters manually.

Pega
March 18, 2015 - 7:04pm

Apologies, I don't know why the comment was added twice

Pega
March 23, 2015 - 11:11pm

Hi SaurabhFS, petej1,

Thank you for the response. I was able to work-around by preparing temporary page (tempEscape in my case) which is to escape the page I need from pagelist. Once all the iteration of the pagelist is done and all the pages I need are escaped (page-copy with append) to newly created tempEscape page, I removed the original pagelist.

I used the data from tempEscape for further processing, but if the page name has to be changed to the original pagelist name, I think you can rename the name to the original name.

Thanks.