The following order of events should happen in my Oracle APEX app:
I tried many ways to accomplish this, but all failed. The obvious solution would be two dynamic actions on the button click, but I learned that the order of the actions is not guaranteed, and the Javascript is executed even after an error in the validation or submit.
Now I think I have to do it with Javascript in a single dynamic action (button click on the modal dialog) like this:
// Validate and submit.
apex.page.submit( {
validate: true,
} );
// Other JS code on successful submit, which is accessing page items.
... $v("myItem") ...
// Close modal dialog.
apex.navigation.dialog.close(true);
How can I check if apex.page.submit was successful? And will the javascript be able to access item values entered by the user?
By the way, I don't want to put this Javascript on the parent page, because there will be multiple such modal dialogs, and I prefer to keep their respective logic separate, and not turn the parent page into a "God object".
Thank you in advance.
This isn't an answer to your question, because I believe what you want is simply not possible. To understand why, you need to check how APEX processes work.
Now... javascript is client side only. and only in phase 2 can client-side code be executed. Once a page is submitted, the client can no longer be accessed. So "execute javascript" after "server side validations" is simply not possible in APEX. javascript can be executed onload OR when the page is rendered via an event OR before page submit. That's it in the current version of apex (23.1).