Sign Up

❇️ OrclQA.Com is a question and answer forum for programmers.
❇️ Here anyone can ask questions and anyone can answer to help others.
❇️ It hardly takes a minute to sign up and it is 100% FREE.

Have an account? Sign In


Have an account? Sign In Now

Sign In


Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.


Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

Oracle APEX Tutorials & Forum

Oracle APEX Tutorials & Forum Logo Oracle APEX Tutorials & Forum Logo

Oracle APEX Tutorials & Forum Navigation

  • Home
  • Oracle Apex
  • PL/SQL
  • SQL
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Ask Question
  • Write a Tutorial
  • Tools
    • Oracle Table Script Generator
    • PL/SQL Package Generator
  • Users
  • Tags
  • FAQs
  • Badges
  • Home
  • Oracle Apex
  • PL/SQL
  • SQL
pavlos
pavlos

pavlos

  • 37 Questions
  • 107 Answers
  • 1 Best Answer
  • 376 Points
View Profile
  • 1
pavlosGuru
Asked: August 18, 20202020-08-18T04:01:01+05:30 2020-08-18T04:01:01+05:30

How to update column when dialog is closed?

  • 1

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!

oracle apex
  • 13
  • 1k
  • 0
  • 0
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
Answer

13 Answers

  1. Vinish Kapoor

    Vinish Kapoor

    • 1 Question
    • 727 Answers
    • 62 Best Answers
    • 4k Points
    View Profile
    Vinish Enlightened
    2020-08-18T06:16:22+05:30Added an answer on August 18, 2020 at 6:16 am
    This answer was edited.

    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:

    apex.message.alert('Test');

    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.

    • 1
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • pavlos

      pavlos

      • 37 Questions
      • 107 Answers
      • 1 Best Answer
      • 376 Points
      View Profile
      pavlos Guru
      2020-08-18T12:56:33+05:30Replied to answer on August 18, 2020 at 12:56 pm

      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.

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
      • Vinish Kapoor

        Vinish Kapoor

        • 1 Question
        • 727 Answers
        • 62 Best Answers
        • 4k Points
        View Profile
        Vinish Enlightened
        2020-08-18T14:20:56+05:30Replied to answer on August 18, 2020 at 2:20 pm

        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. 

        • 0
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
        • pavlos

          pavlos

          • 37 Questions
          • 107 Answers
          • 1 Best Answer
          • 376 Points
          View Profile
          pavlos Guru
          2020-08-18T14:47:34+05:30Replied to answer on August 18, 2020 at 2:47 pm
          This answer was edited.

          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.

          • 0
          • Share
            Share
            • Share on Facebook
            • Share on Twitter
          • Vinish Kapoor

            Vinish Kapoor

            • 1 Question
            • 727 Answers
            • 62 Best Answers
            • 4k Points
            View Profile
            Vinish Enlightened
            2020-08-18T14:52:17+05:30Replied to answer on August 18, 2020 at 2:52 pm

            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.

            • 1
            • Share
              Share
              • Share on Facebook
              • Share on Twitter
        • pavlos

          pavlos

          • 37 Questions
          • 107 Answers
          • 1 Best Answer
          • 376 Points
          View Profile
          pavlos Guru
          2020-08-18T14:50:34+05:30Replied to answer on August 18, 2020 at 2:50 pm

          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.

          • 0
          • Share
            Share
            • Share on Facebook
            • Share on Twitter
    • 0 Questions
    • 22 Answers
    • 1 Best Answer
    • 0 Points
    View Profile
    [Deleted User]
    2020-08-18T14:22:07+05:30Added an answer on August 18, 2020 at 2:22 pm
    This answer was edited.

    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/

    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • pavlos

      pavlos

      • 37 Questions
      • 107 Answers
      • 1 Best Answer
      • 376 Points
      View Profile
      pavlos Guru
      2020-08-18T14:44:34+05:30Replied to answer on August 18, 2020 at 2:44 pm

      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

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
  2. Vinish Kapoor

    Vinish Kapoor

    • 1 Question
    • 727 Answers
    • 62 Best Answers
    • 4k Points
    View Profile
    Vinish Enlightened
    2020-08-18T15:18:35+05:30Added an answer on August 18, 2020 at 3:18 pm

    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:

    body .ui-dialog .ui-dialog-titlebar-close {display: none;}

    Note: Do not add the above CSS to the dialog page.

    Even I used this approach sometimes.

    • 1
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • pavlos

      pavlos

      • 37 Questions
      • 107 Answers
      • 1 Best Answer
      • 376 Points
      View Profile
      pavlos Guru
      2020-08-18T16:23:01+05:30Replied to answer on August 18, 2020 at 4:23 pm

      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.

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
      • Vinish Kapoor

        Vinish Kapoor

        • 1 Question
        • 727 Answers
        • 62 Best Answers
        • 4k Points
        View Profile
        Vinish Enlightened
        2020-08-18T16:35:56+05:30Replied to answer on August 18, 2020 at 4:35 pm

        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.

        • 1
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
        • pavlos

          pavlos

          • 37 Questions
          • 107 Answers
          • 1 Best Answer
          • 376 Points
          View Profile
          pavlos Guru
          2020-08-18T16:40:27+05:30Replied to answer on August 18, 2020 at 4:40 pm
          This answer was edited.

          Thanks, it works. Can I delete keyboard shortcut (esc)?

          • 0
          • Share
            Share
            • Share on Facebook
            • Share on Twitter
          • Vinish Kapoor

            Vinish Kapoor

            • 1 Question
            • 727 Answers
            • 62 Best Answers
            • 4k Points
            View Profile
            Best Answer
            Vinish Enlightened
            2020-08-18T18:26:42+05:30Replied to answer on August 18, 2020 at 6:26 pm

            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:

            closeOnEscape:false

            Below is the screenshot:

            Disable dialog close on escape key.

            • 1
            • Share
              Share
              • Share on Facebook
              • Share on Twitter
  3. pavlos

    pavlos

    • 37 Questions
    • 107 Answers
    • 1 Best Answer
    • 376 Points
    View Profile
    pavlos Guru
    2020-11-10T22:47:07+05:30Added an answer on November 10, 2020 at 10:47 pm

    Hi!

    I found a solution on this blog 🙂

    • 1
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • Vinish Kapoor

      Vinish Kapoor

      • 1 Question
      • 727 Answers
      • 62 Best Answers
      • 4k Points
      View Profile
      Vinish Enlightened
      2020-11-11T07:52:34+05:30Replied to answer on November 11, 2020 at 7:52 am

      Yes, that is a good one.

      • 1
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
  4. Knr3337254

    Knr3337254

    • 0 Questions
    • 1 Answer
    • 0 Best Answers
    • 25 Points
    View Profile
    Knr3337254 Contributor
    2021-12-23T20:49:37+05:30Added an answer on December 23, 2021 at 8:49 pm

    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.

    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • pavlos

      pavlos

      • 37 Questions
      • 107 Answers
      • 1 Best Answer
      • 376 Points
      View Profile
      pavlos Guru
      2021-12-30T17:51:56+05:30Replied to answer on December 30, 2021 at 5:51 pm

      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.

       

      • 1
      • Share
        Share
        • Share on Facebook
        • Share on Twitter

You must login to can add an answer.


Forgot Password?

Sidebar

Explore

  • Ask Question
  • Write a Tutorial
  • Tools
    • Oracle Table Script Generator
    • PL/SQL Package Generator
  • Users
  • Tags
  • FAQs
  • Badges

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
© 2022 OrclQA.Com. All Rights Reserved.
Privacy Policy - About Us