Posted: 26 Oct 2017 18:20 EDT Last activity: 2 Nov 2017 15:26 EDT
How Does pzdoGridAction Work?
I am using PRPC 7.2.2, which contains the pzDoGridAction (Pega-UIEngine:07-10-15) activity.
When you go to the advanced portion of the operations tab on a repeat grid, you will see that the options for running a pre and post condition are conditionally selected. Looking at this rule however, there is no precondition on step 1, which runs the pyPreGridUpdate activity. I would expect that step 1 would have a pre condition that checks if the grid's "Run activity before grid update" option is selected.
Also, I have traced and verified that steps 2, 4, and 5 will never run. The reason for this is because these steps do not have anything defined for the "if false" option on the pre condition. If I change the "if false" options to be "Continue Whens" then the steps properly run.
Right now, my problem is that I have a grid that upon checking the checkbox, I make a service call, and if it fails, I display an error on the row. If I then sort, or go to a new page, step 1 ALWAYS runs, which has logic to clear messages. I do not want to allow the user to continue if there was an error on select, however after the grid action, the error is always gone. Ideally, because "Run activity before grid update" is not selected, this step would not run. My first idea was to add logic to the pyPreGridUpdate and pyPostGridUpdate activities to store and map back those errors, however this is not possible because the post activity never runs.
From what I can tell, this is buggy behavior, and has never been properly implemented. I could override the pz activities, but would like to avoid that. Likewise, I am doubtful that creating an SR to deal with this will yield me the desired outcome.
I ended up just enforcing the grid to deselect the row and display the error, when there was a failure...it gives me the desired functionality without having to maintain an error flag.
My concern with the pzDoGridAction activity is just that from looking at it, it looks like it does not do what it is intended to do. The grid control provides the option to add your own pre and post processing activities, but there is no pre condition on the step that runs the pre activity (so the pre activity always runs), and the post activity does not have a "continue whens" option on it, so if you were to define a post activity on the grid, that step would never run. I've never used those options in the past because it never seemed to work, and now I understand why it does not work.
I guess the purpose of this post was not to figure out how to handle the grid refresh wiping my error, but rather to see if someone would say "oh, I see what you are saying...yes, that is a defect"
Side note: pzDoGridAction is ultimately the activity that processes the pre and post grid action activities that are defined in the advanced portion of the repeat grid control. I think that the internal API is defective.
Though the description of step 1 in pzDoGridAction says "Execute pyPreGridUpdate", it does other things as well (including clearing the messages for fresh execution). This is by design. If you want users to not be able to navigate away from the page, set the error on Section page context rather than row page context. pzDoGridAction Activity should not clear messages from the Section context page.