4 Replies Latest reply: Jul 15, 2014 2:43 AM by fac586 RSS

    How do I reset an item after a page/item validation error occurs?

    kab123

      I'm using APEX 4.1, and I want to prevent users from updating data on a form after a particular item has been set to Y through a computation.   So I added something in the save button to only be visible when the value in this item is N.   However whenever an item or validation error occurs, but the computation succeeded in setting the one value to Y, the save button disappears and now the users can't correct the issue and save the form.   Is there a way for me to detect when an item or validation error occurs to then reset the one item value back to N so that the update button stays visible so they can correct the error?

        • 1. Re: How do I reset an item after a page/item validation error occurs?
          AquaNX4

          Hello kab123:

           

          Instead of putting a conditional display on the save button which is tied to the result of the computation, why don't you just put a page level validation that will not allow a save if the value of the item is N.  That way the save is always visible, but it is useless if your item = N. 

           

          This material is good to read too:

           

          Working with Application Pages

          • 2. Re: How do I reset an item after a page/item validation error occurs?
            kab123

            I tried that, but even in that case, if the one computation has already set my item to Y, but there was an item or validation error, the page validation would still complain (even after I fixed the item error) that the one item is still Y and won't allow the save to happen.    So how do item set my item back to N when an error occurs, so that when they hit save again, the page can rerun the computation to set it back to Y and the form will save?

            • 3. Re: How do I reset an item after a page/item validation error occurs?
              AquaNX4

              Kab123:

               

              Hope you are well.  Instead of focusing on resetting the item, this is what I was trying to tell you (1 of many solutions)

               

              The same code you used to compute the value of the item should ONLY be used as a validation.  In other words:

               

              1:     Delete the computation (reset the conditional display to always too, and delete the hidden item you used for either "N" or "Y")

              2:     Use ONLY the page validation to save a record if the data passes the test (validation).

               

              Understand?  You don't need to have the computation IF ALL you are doing is validating the data to save or not to save if certain conditions are met.  All you need is a validation which allows or disallows the saving of the record.

               

              Aqua

              • 4. Re: How do I reset an item after a page/item validation error occurs?
                fac586

                kab123 wrote:

                 

                I'm using APEX 4.1, and I want to prevent users from updating data on a form after a particular item has been set to Y through a computation.   So I added something in the save button to only be visible when the value in this item is N.   However whenever an item or validation error occurs, but the computation succeeded in setting the one value to Y, the save button disappears and now the users can't correct the issue and save the form.   Is there a way for me to detect when an item or validation error occurs to then reset the one item value back to N so that the update button stays visible so they can correct the error?

                You can use the built-in [No] Inline Validation Errors Displayed condition types.

                 

                Reset the flag to "N" in a Before Header PL/SQL process with condition Inline Validation Errors Displayed.

                 

                See this thread for a discussion of the implications of these conditions and the restrictions that require use of a process rater than a computation: Checking if Inline Validation Error Message is shown via PL/SQL

                 

                You have not indicated when the computation of the flag occurs. Depending on the nature of the computation, you could reverse this logic and execute it as a Before Header computation dependent on the No Inline Validation Errors Displayed condition.

                 

                A better solution is possible in APEX 4.2, where the logic used to set the flag to "Y" could simply be applied to make the region or page read-only.