diff --git a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
index 557e44b7a..4c2cb04ab 100644
--- a/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
+++ b/web/pgadmin/browser/server_groups/servers/roles/static/js/role.js
@@ -748,6 +748,41 @@ define('pgadmin.node.role', [
                 // set default role operation as reassign
                 this.view.model.set({'role_op': 'reassign'});
               },
+              confirmDialog: function(data, url) {
+
+                var roleOp = data.role_op,
+                  confirmBoxTitle = utils.titleize(roleOp),
+                  title = utils.sprintf('%s Objects', confirmBoxTitle),
+                  msg = utils.sprintf('Are you sure you wish to %s all the objects owned by the selected role?', roleOp);
+
+                alertify.confirm(
+                  gettext(title),
+                  gettext(msg),
+                  function() {
+                    axios.post(
+                      url,
+                      data
+                    ).then(function (response) {
+                      if(response.data)
+                        alertify.success(response.data.info);
+                    }).catch(function (error) {
+                      try {
+                        const err = error.response.data;
+                        alertify.alert(
+                          gettext('Role reassign/drop failed.'),
+                          err.errormsg
+                        );
+                      } catch (e) {
+                        console.warn(e.stack || e);
+                      }
+                    });
+                  },
+                  function() { return true; }
+                ).set('labels', {
+                  ok: gettext('Yes'),
+                  cancel: gettext('No'),
+                });
+              },
               // Callback functions when click on the buttons of the alertify dialogs
               callback: function(e) {
                 if (e.button.element.name == 'dialog_help') {
@@ -757,38 +792,8 @@ define('pgadmin.node.role', [
                   return;
                 }
                 if (e.button.text === gettext('OK')) {
-
-                  let roleReassignData = this.view.model.toJSON(),
-                    roleOp = roleReassignData.role_op,
-                    confirmBoxTitle = utils.titleize(roleOp);
-
-                  alertify.confirm(
-                    gettext('%s Objects', confirmBoxTitle),
-                    gettext('Are you sure you wish to %s all the objects owned by the selected role?', roleOp),
-                    function() {
-                      axios.post(
-                        finalUrl,
-                        roleReassignData
-                      ).then(function (response) {
-                        if(response.data)
-                          alertify.success(response.data.info);
-                      }).catch(function (error) {
-                        try {
-                          const err = error.response.data;
-                          alertify.alert(
-                            gettext('Role reassign/drop failed.'),
-                            err.errormsg
-                          );
-                        } catch (e) {
-                          console.warn(e.stack || e);
-                        }
-                      });
-                    },
-                    function() { return true; }
-                  ).set('labels', {
-                    ok: gettext('Yes'),
-                    cancel: gettext('No'),
-                  });
+                  let roleReassignData = this.view.model.toJSON();
+                  this.confirmDialog(roleReassignData, finalUrl);
                 }
               },
             };
