2 Replies Latest reply on Mar 15, 2019 8:32 AM by Niels IH

    Apex equivalent of pre-insert / pre-update forms trigger?

    Niels IH



      In forms you can have some pl/sql code that does some stuff on the database before a record is inserted/updated.

      In this pl/sql you can have user interaction with alert- / confirmation dialogs like :  "This research type is no longer valid. Do you wish to create a new research anyway?"  <yes> <no> <cancel>


      The user clicks <yes> , the pl/sql processing continues, creates a new research and when it completes succesfully the insert/update of the record(s) also complete.

      When the user clicks <no>, the new research is not created but the insert/update action of the record(s) complete.

      When the user clicks <cancel>, all processing stops.


      I'm having a hard time to build this functionality in Apex with the interactive grid.  You can build validations- and you can have processing with pl/sql on the server but you cannot have user interactions during validations or processing like a confirmation dialog as far as i know.


      Making an ajax call before the submit action of the interactive grid has drawbacks like what if the  ajax process completes and data is commited to the database but the following IG automatic row processing or a validation on the record subsequently fails?

      What would be the best way to do something like this in Apex with the interactive grid?



        • 1. Re: Apex equivalent of pre-insert / pre-update forms trigger?

          I am currently also working on a Forms to Apex conversion and encounter the same problems. Alas, you do have to make Ajax calls and confirm dialogs before actually submitting the page.

          This (in my case anyway) means a redesign of Forms processing.  All the necessary checks need to be done before submitting the page. So, a Form proces like this:


          <do something>


          <do something>


          <final commit>


          has to be redesigned to


          <do some checks via an Ajax call without committing data>


          <post and commit>


          This usually means you first get all the confirmation messages back in one message instead of multiple confirms (as was usually the case in Forms).


          If this kind of redesign is not possible, you should hold temporary results in a collection before actually committing the data.


          BTW: it gets worse when you have Forms with a POST-FORMS-COMMIT trigger!

          • 2. Re: Apex equivalent of pre-insert / pre-update forms trigger?
            Niels IH

            Thanks for your reply

            Perhaps collections are the way to go. I would rather not offcourse.

            I think it will mean that i have to rewrite the standard save action of the interactive grids to process the row(s) through ajax and handle the user interaction before they are actually submitted by the grid.


            Perhaps i can come up with some plugin design to do this in a more general way..