Hi!
I'm trying to update flag column when dialog is closed, column is 1 or 0 when column is 1 it means that another user edit record (pessimistic locking).
I tried with dynamic action, event: dialog closed, which is JavaScript expression contain "window", true action is pl/sql code. But, it wont update column 🙁
I hope I explained problem well.
Thanks in advance!
Vinish Kapoor
Firstly, try to find whether the dynamic action event is firing or not. You can do this by simply running JavaScript code instead of PL/SQL code action type. You can add the alert message in the JS code, for example:
Now test it by closing the dialog and see if you are getting this message or not. If not, then you have to change the event type or try to write the DA on the button from which you opening the dialog or on the region where the link or button exists.
And when finally you will find the right option, then you can change the action type to PL/SQL code again, and then it will surely update.
But if it still not update, then you have to check that the table is not locked from the previous update.
Let me know if still any issues.
pavlos
Hi Vinish!
When I added JS code: "apex.message.alert('Test');" I got alert only when I save data. I tried to create DA on that region but works same.
Vinish Kapoor
Hi Pavlos,
If you are getting the alert message, it means that the DA is executing on the close dialog event, but it seems that your update statement is not working.
So now, you have to check your SQL update statement, whether it is running correctly or not.
Did you have specified the items for the Submitted Items option? Suppose if you are using any page item in your PL/SQL code, then you have to specify items in the Submit items property.
pavlos
Sorry, I think I described the problem incorrectly.
I need to update column when user close modal dialog on X button or Cancel button. When user click on Save column is updated. Problem is when user close dialog without saving, flag column is steel 1. Problem is when user close dialog without saving, flag column is still 1.
Vinish Kapoor
I understand your issue, that is what I am saying, you need to check your PL/SQL code.
Because if on the parent page DA is working correctly using the JavaScript expression (window), or on the region, then you need to check your PL/SQL code only.
Because if the event is firing correctly, then your PL/SQL code will be executed.
pavlos
I need to update column when user close modal dialog on X button or Cancel button. When user click on Save column is updated. Problem is when user close dialog without saving, flag column is still 1.
If i am not understanding incorrectly, you are looking to execute dynamic action on dialog close so that you can update the report column 1 or 0. Please try:
https://blogs.ontoorsolutions.com/post/refresh_on_dialog_close/
pavlos
Hi!
I tried this, but it work only when user click on save button (submit page), I need to update column when user close modal dialog on X button or Cancel button
Vinish Kapoor
You can do one more thing.
Hide the close (X) button of the dialog so that the user has to click on the Cancel/Close button to close the dialog.
Add the following CSS to the parent page. In the page settings > Inline CSS:
Note: Do not add the above CSS to the dialog page.
Even I used this approach sometimes.
pavlos
I deleted X button, and DA on cancel button which is submit page, works now. But, user can close dialog using keyboard shortcut (ESC). I noticed that DA works only when page is submitted.
I created demo app: https://apex.oracle.com/pls/apex/petarapex/r/test-da/home?session=127542306346046
Workspace: petarapex, User: [email protected], Pass: [email protected]
The dialog opens when the user clicks on the ID.
Vinish Kapoor
On your dialog page's cancel/close button change the DA action type to Close Dialog.
Currently, it seems that it is set to Cancel Dialog, in this case, the parent page Close Dialog event will not fire.
pavlos
Thanks, it works. Can I delete keyboard shortcut (esc)?
Vinish Kapoor
Hi Pavlos,
You can disable the escape key for the dialog. Follow these steps:
Open your dialog page and at the right side in the property section, under the Dialog section, you will find property Attributes. Add the following code in it:
Below is the screenshot:
pavlos
Hi!
I found a solution on this blog 🙂
Vinish Kapoor
Yes, that is a good one.
Knr3337254
Hi,
pavlos I am facing the same issue, Will you tell me the solution that worked for you step by step.
Thank you in advance.
pavlos
Hi! Sorry for my late answer.
Create function on parent page:
function customEvent(event, data){
apex.event.trigger(document, event, data);
}
Then on the Modal page in dialog section add:
close: function() { customEvent('customDialogClose', {modalPageId: 'MODAL_CLOSE_FIXED'});}
Add dynamic action:
Event: Custom
Custom Event: customDialogClose
Selection Type: JavaScript Expression
JavaScript Expression: document
and for true action add DML statement.