Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Confirmation message on button on order guide

Nicole_k
Kilo Expert

Hi All,

I am currently scoping order guides and the functionality.

One thing I am noting on Step 2 of the guide there is a previous button.

If that button is selected then it will go back to the previous screen but the data on step 2 will be lost.

I want to put a confirmation message for the end users when previous is selected display popup

"All your current information will be lost, Do you wish to continue?" 

I have found the following in the order guide widget but my lack of coding knowledge is not helping. How can I add a confirmation popup that if ok is selected it proceeds, if cancel is selected it stays on the current screen

 

HTML - 

<div class="pull-right">
<button ng-hide="guide_step != 1 || submitted" name="submit" ng-click="goPrev()" class="btn btn-default padder pull-left-xs" ng-class="{'m-r-6': guide_step < 2}">{{::m.prevMsg}}</button>

Server script - 

m.prevMsg = gs.getMessage("Previous");

 

Client controller - 

$scope.goPrev = function() {
$scope.includedItems.forEach(function (item) {
item.isOpen = false;
})
$scope.guide_step--;
if($scope.guide_step==0)
spSCNavStateManager.unregisterForms(Object.keys(includedGformInstances));
}

 

1 ACCEPTED SOLUTION

John Longhitano
Kilo Guru

You could use spModal.confirm()  inside of the #scope.goPrev function block.  See docs below it has helped me in the past it's pretty handy

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=SPM-confirm_S

View solution in original post

7 REPLIES 7

John Longhitano
Kilo Guru

You could use spModal.confirm()  inside of the #scope.goPrev function block.  See docs below it has helped me in the past it's pretty handy

https://developer.servicenow.com/app.do#!/api_doc?v=madrid&id=SPM-confirm_S

You'd also have to clone the widget if you planned on doing it that way.

Hi John,

Turns out I was just over complicating it. Your reference material really helped.

This is what I ended up with - 

 

Modified "previous" button html

 ng-click="c.onConfirm()"

 

Added the below to the Client controller script

c.onConfirm = function() {
spModal.confirm("Going back to the previous screen means you will lose any information you have entered in this step. Are you sure you want to go back?").then(function(confirmed) {
$scope.goPrev();
})
}

Glad you got it working!