Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Confirmation box on click of Cancel button in Service Portal

Mohit Kaushik
Mega Sage
Mega Sage

Hi I am trying to put a confirmation popup upon clicking of a UI action on my UI actions for request form Widget in service portal. Can anyone suggest me how can i achieve that.

There is simple list on Service portal which is displaying my requests. Once we open a request form we can see few action in right side of the form. For those actions i have created a widget called UI actions and in those UI actions there is one "cancel" button. Now what my customer wants is i need to put a confirmation message before cancelling the request. It will we great if someone can suggest me how to achieve it.

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)
1 ACCEPTED SOLUTION

Mohit Kaushik
Mega Sage
Mega Sage

Hi thanks for your response, but I have used spModal to achieve this. The spModal class provides an alternative way to show alerts, prompts, and confirmation dialogs and can be used in Client scripts of Service portal. I got it from the below mentioned link.

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...

 

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

View solution in original post

2 REPLIES 2

Sam Dey1
Kilo Guru

So in your widget, on the cancel button add this (if you are not calling a function there) - < ng-click = "userCancelConfirm()">

If you are calling a function on ng-click in the cancel button (or if you use the userCancelConfirm() function)

 

// userCancelConfirm function definition

in Client Script of the widget - 

 

$scope.userCancelConfirm= function(){
var userConfirm = confirm("Do you want to cancel this");

if(userConfirm){ //userConfirm is true now
//Do something on
alert("I am cancelled with confirmation");
}
}; 

 

Mohit Kaushik
Mega Sage
Mega Sage

Hi thanks for your response, but I have used spModal to achieve this. The spModal class provides an alternative way to show alerts, prompts, and confirmation dialogs and can be used in Client scripts of Service portal. I got it from the below mentioned link.

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...

 

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)