I was reading Martin Giffy D’Souza’s article on the apex.da.cancelEvent function and thought it would be interesting to talk about another undocumented JavaScript function called apex.da.resume. This function is closely related to the Wait For Result setting within a dynamic action. You typically check this option for a so-called asynchronous action that should wait to finish before executing any following, dependent actions. As soon as the asynchronous action gets back the result it was waiting for, the apex.da.resume function is called in the background, which causes APEX to start executing the next action.

Wait For Result option
Wait For Result option

You won’t encounter the apex.da.resume function in regular APEX development, but it is important when creating a dynamic action type plugin. That’s because you can choose to include the Wait For Result attribute in your plugin. Then it’s you to decide when to call the apex.da.resume function, so that any following actions are executed. The apex.da.resume function accepts two parameters:

* @param {function} pCallback
*   Reference to callback function available
*   from the this.resumeCallback property.
* @param {boolean} pErrorOccurred
*   Indicate to the framework whether an error
*   has occurred. If an error has occurred and
*   the action's 'Stop Execution on Error'
*   attribute is checked, execution of the
*   dynamic action will be stopped.

I ran into this function while creating the Alertify APEX plugin. One part of this plugin allows you to create customized browser dialogs. The confirmation dialog, for example, contains an OK and Cancel button. I wanted to achieve the same behaviour as the built-in confirm dynamic action in which subsequent actions are executed only if the OK button is clicked. A perfect use case for the apex.da.resume function:

confirm: function (pThis) {
  alertify.confirm(this.util.replaceItems(pThis.action.attribute04), function (e) {
    if (e) {
      if (pThis.action.waitForResult) {
        apex.da.resume(pThis.resumeCallback, false);
    } else {