Creating a confirm prompt within a UI action

Ben Cervantes
Kilo Expert

Hello All, 

I am trying to create a confirm prompt within the Reject UI action on the Change Request table. However, the client side "onclick" function does not appear to be working as it will not display the confirm box when rejecting a request. Something to note is that the rejection is being done in the list view for the Approvers tab. Our CAB admin will go to his name and right click and hit approve/reject. This maybe the reason the code UI action is not working but I needed some help getting in the right direction. 

find_real_file.png

 

//Client-side 'onclick' function 
function rejectRequest () {
    var answer = confirm("Are you sure you want to Reject this request?");
    if (answer == true){
        gsftSubmit(null, g_form.getFormElement(), 'reject');
    }
    else {
        return false;
    }
}

//Code that runs without 'onclick'
if (typeof window == 'undefined') {
    runRejectBusRuleCode();
}


//Server-side code 
function runRejectBusRuleCode() {
    current.approval = "rejected";
    current.update();
    
    new UIActionUtils().approvalsNoLongerRequired(current.sys_id);
}
1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

I don't think this is going to work for you since you're trying to do this on a list. I see g_form.getFormElement() - g_form is only available when you load a form.

Check the OOB UI actions to see if any list UI actions have a confirm in the script. I see a few with the filter "List action | is | true AND Script | contains | confirm".

Change YOURINSTANCENAME to your instance name in the URL below.

https://YOURINSTANCENAME.service-now.com/sys_ui_action_list.do?sysparm_query=list_action%3Dtrue%5EscriptLIKEconfirm&sysparm_list_mode=grid

View solution in original post

1 REPLY 1

Chuck Tomasi
Tera Patron

I don't think this is going to work for you since you're trying to do this on a list. I see g_form.getFormElement() - g_form is only available when you load a form.

Check the OOB UI actions to see if any list UI actions have a confirm in the script. I see a few with the filter "List action | is | true AND Script | contains | confirm".

Change YOURINSTANCENAME to your instance name in the URL below.

https://YOURINSTANCENAME.service-now.com/sys_ui_action_list.do?sysparm_query=list_action%3Dtrue%5EscriptLIKEconfirm&sysparm_list_mode=grid