Apex 21.2 - I have a dialog form to create/edit shipping addresses. When a new shipping address is added/changed and the submit button is clicked, I want to use the Google Maps API distanceMatrix to retrieve mileage to the destination from our warehouse and save the value in the P27_Distance field prior to the submit.
I have DAs setup on the CREATE and SAVE buttons to execute a SetValue Javascript Expression followed by a Submit Page. "Wait to finish" is selected but the submit occurs before the setValue has completed the callback.
I have tried using async/await with promises but the value is set to [object] promise. Of course the SQL fails because the field is not numeric.
How can I make the setValue wait until the google service has responded before processing the submit? Is there a better way to approach this?