2 Replies Latest reply on Jan 10, 2019 4:20 PM by partlycloudy

    IG - Sync column with external system


      APEX 18.2


      When the value of one of the columns (STATUS, rendered as a select list) on an editable IG changes and the new value is in a pre-determined set of values (e.g. x,y,z), the value should be POST-ed to an external system using a provided REST API endpoint. The POST payload has just 2 data elements -  A hidden column on the row and the select list value.


      So far so good, just create a Change DA on STATUS, get the new value using $(this.triggeringElement).val() and use jQuery $.ajax to invoke the external API and provide a client-side notification message.


      But error handling seems complicated


      1. What if the external system throws an error (returns a non HTTP 200 code)? How can the IG column value be reverted back?

      2. User makes a bunch of updates on the IG and then decides to leave the page without saving the changes. Now the 2 systems are out of sync

      3. Any other error condition I am not thinking of


      One way to handle this could be to let the server-side IG Save do its thing and then gather all the changes from the client model (or is it too late by this point?) and iterate over them to POST them one by one. Disadvantages - No instant client-side feedback like with the above approach.


      Another idea could be to use apex.server.process to persist the STATUS update to Oracle and call the external API in the success callback.


      Any ideas? Thanks