Adding Pop-up message along with Buttons in UI action

Rajesh Bandila
Tera Contributor

Hi Everyone,

 

I have an UI action called “Request Document” button. When I click on UI action I would like a popup message to appear that says "Are you sure you want to send this Request Document."

 

In the popup window, there should be two buttons. “Proceed” and “Cancel”. Clicking on the “Proceed” button will launch process by sending the Request document. Clicking on the “Cancel” button will take back to the current page.

 

Please help me how to achieve this?

Thanks!!

1 ACCEPTED SOLUTION

@Rajesh Bandila : Below is the sample code that will help you. Enable client checkbox on UI Action and provide an action name and Onclick function name. 

 

sainathnekkanti_0-1703012114927.png

function requestDocument() {
    var answer = confirm("Are you sure you want to send this Request Document.");
    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'action_name');
    } else {
        return false;
    }
}

if (typeof window == 'undefined') {
    // Add your existing server side logic here
}

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
 
Regards,
Sainath N

 

 

View solution in original post

9 REPLIES 9

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Rajesh Bandila ,

 

If ur UI action is client then u can use confirm method the way we use alert in client script.

 

It will give u a popup with OK n cancel button.

 

If pressed ok it will move ahead if pressed cancel it will comeback to that same page.

 

But u do need to code that.

Attaching one sample link for your reference

https://www.servicenow.com/community/developer-forum/add-confirm-pop-up-message-in-ui-action/m-p/197...

 

Thanks,

Danish

 

Thanks for your response @Danish Bhairag2 

 

Currently my ui action is Server side script. Could you please provide the code for that? It will help full for me to move further.

@Rajesh Bandila : Below is the sample code that will help you. Enable client checkbox on UI Action and provide an action name and Onclick function name. 

 

sainathnekkanti_0-1703012114927.png

function requestDocument() {
    var answer = confirm("Are you sure you want to send this Request Document.");
    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'action_name');
    } else {
        return false;
    }
}

if (typeof window == 'undefined') {
    // Add your existing server side logic here
}

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.
 
Regards,
Sainath N

 

 

Thanks for your response @Sainath N 

 

Code is working as expected and In the pop up message buttons are showing "OK" and "Cancel". here my question is, how to place the "Proceed" button in place of "OK"? or Can we replace it to "OK" to "Proceed"?