5 Replies Latest reply on Nov 8, 2019 11:01 PM by Eslam_Elbyaly

    prevent process execution when button pressed

    Eslam_Elbyaly

      Apex 18.2.

      Hi,

       

      I have built a report with a form on a table using the wizard. The form is modal. Then I created an IG to join it to the form as master-detail regions through setting the FK column to the PK page item value.

       

      Processes in the page,

      1- get_pk -- to get the value from db sequence.

      2- process row of master form.

      3- set_fk -- to set the IG fk column's value.

      4- IG ARP.

      5- Reset Page.

      6- Close dialog.

       

      - The detail table's fk constraint is cascading. So when the master record is deleted, the detail is deleted as well.

      - the FK column has a not null constraint too.

      - My problem is,

      when I edit a record from the report, the form is opened > add a record to the IG> then click the "DELETE" button. It shows a db error Edited: " Primary key not found".

       

      Edited:

      - I guess that the problem is because the IG ARP is executed then, after the SET_FK is executed and it tries to insert the newly created record with the pk value whose record was just deleted. So I believe that the solution is to prevent it from executing when the "DELETE" button is clicked.

       

      - I tried setting the server side condtion to "REQUEST != DELETE", but it still executes the process! Am I missing something? Is there a better solution?

        • 1. Re: prevent process execution when button pressed
          Rick-Pick

          I'm not completely sure what you are trying to achieve, but the following might help.

           

          Automatic Row Processing addresses each changed row in the grid according to whether it has been created, updated or deleted. To avoid the kind of conflict I think you're referring to, you can substitute your own code in the ARP by changing the Target Type to PL/SQL Code.

           

          In your code, use APEX$ROW_STATUS to determine whether the record currently being processed is created (C), updated (U) or deleted (D). Some or all of your processing logic can then be placed in this one procedure. A good method is to declare records for the table(s) you are updating and set them according to the logic you want. Easily refer to the record columns by preceding the column name with a colon as in ":EMP_ID". Then pass the record(s) into one or more packaged procedures to do the inserts etc.

          • 2. Re: prevent process execution when button pressed
            Eslam_Elbyaly

            I wouldn't write code when the built-in feature exists. Especially, in such a situation when I might need to prevent other processes from executing.

             

            Any clue why "request != DELETE" condition does not work? ?

            • 4. Re: prevent process execution when button pressed
              Rick-Pick

              If your DELETE button is submitting the page, that might explain it. IG's with an ARP are saved when the grid's Save button is pressed or the save action called, or when the page is submitted. If "SET-FK" has just updated the IG record the ARP would think it needed to process an update. Can you bypass your "SET-FK" function with the request != DELETE condition instead of the ARP? Or is that what you're already trying to do?

              1 person found this helpful
              • 5. Re: prevent process execution when button pressed
                Eslam_Elbyaly

                Rick-Pick wrote:

                 

                If your DELETE button is submitting the page, that might explain it. IG's with an ARP are saved when the grid's Save button is pressed or the save action called, or when the page is submitted. If "SET-FK" has just updated the IG record the ARP would think it needed to process an update. Can you bypass your "SET-FK" function with the request != DELETE condition instead of the ARP? Or is that what you're already trying to do?

                It does not work out even if SET_FK's condition is set to "Never". And I think that's because My PK is populated through a database trigger. I think it causes the newly created record is marked for insert. Not sure about that but I think this is the reason behind it.

                 

                I figured it out. The execution condition should be "once" not "For each row".