Workspace UI Action confirm not working correctly

JordyZ
Mega Sage

Hi,

 

I have a custom UI Action for workspace form. How it's supposed to work: upon pressing the UI action, it should show a pop-up confirmation window. After confirming, it should create a new case. The problem I'm facing is that when pressing the UI action, the confirmation popup appears but before I even can press confirm, the new case already gets created. 

JordyZ_0-1718939079556.png
How do I make sure the new case only gets created after I press confirm?

I've followed the solution of this thread, but to no avail.

https://www.servicenow.com/community/now-platform-forum/workspace-experience-ui-action-with-g-modal-...

Any help would be appreciated!

1 ACCEPTED SOLUTION

JordyZ
Mega Sage

Found a solution:

function onClick(g_form) {
    if (!confirm(getMessage("Are you sure you want to close this interaction and open a new CC case?"))) {
        return;
    }

    g_form.submit(g_form.getActionName());
}

 

View solution in original post

2 REPLIES 2

Nisha15
Mega Sage
Mega Sage

 

function onClick(g_form) {
  var msg = getMessage("Are you sure you want to take this action?");
    g_modal.confirm(getMessage("Confirmation"), msg, function (confirmed) {
        if (confirmed) {
            g_form.setValue('state', 'closed_complete');
            g_form.save();
        }
    });

    return false;
}

Hi @JordyZ , 

can you try to pass in this format.. 

JordyZ
Mega Sage

Found a solution:

function onClick(g_form) {
    if (!confirm(getMessage("Are you sure you want to close this interaction and open a new CC case?"))) {
        return;
    }

    g_form.submit(g_form.getActionName());
}