I think my app is displaying an incorrect message because I am not grasping how APEX page processing and session state work.
Page 1 of my app contains an interactive grid. Users can select multiple records, click the Save button to save that selection in the database, and then click on a “Create Holds” button on the Actions toolbar.
The “Create Holds” button redirects to page 11, a modal window that prompts for the Hold parameters.
When the user clicks the “Create” button on this modal window, a Dynamic Action executes a PL/SQL procedure which creates the hold records and returns P11_OUTPUT_MSG, which contains the number of records created. The Dynamic Action then executes Close Dialog.
Page 1 contains a Dynamic Action on Dialog Closed. It refreshes the interactive grid then executes an Alert to display P11_OUTPUT_MSG. That message is always one transaction old, however (i.e. if I created 10 holds in the last transaction and 5 holds this time, it will display “10 holds created” instead of 5).


I was thinking that session state would be updated when page 11 is closed, but I guess not?
P11_OUTPUT_MSG is up-to-date when I look at it in Session via the developer toolbar. That, of course is after the process is done.
Is anyone willing to explain this?
I looked at apex_util.set_session_state, thinking I could update session state for P11_OUTPUT_MSG prior to displaying it, but I don't know what the parameters would be.
I'm also wondering if I should be using a page process instead of dynamic action. I'm not clear on when it is better to use one over the other.
Thank you