SP Modal Confirm OOTB shows close modal option

babarat1
Tera Contributor

Hi All,

 

I am trying to user SP Modal Confirm for a message. Client controller as shown below

c.deactivateUser=function(name)
{
spModal.confirm("Are you sure you want to deactivate the user? ").then(function(confirmed) {
if (confirmed) {
c.data.username = name;
c.server.update().then(function(){                                                    
c.data.action='proceed';
c.getUserlist();                                                    
});

}
else
{
spModal.alert("User was not deactivated.");
}
});
}

 

babarat1_0-1675922901959.png

I would want to exclude the "close Modal" functionality. How to do the same? or atleast I do not want the message to show up.

Please help.

 

Thanks

@Community Alums @Basheer @Ankur Bawiskar @Brad Bowman  @Shubham_Shinde 

 

1 ACCEPTED SOLUTION

Hello @babarat1 

If you're trying to pass the data.action to server side script you can do it by using c.server.get({action:"proceed"}), and can access this in server side script by using input.action.
For ex:
/*Client Controller*/
c.server.get({action:"proceed"}).then(function(response){

   c.getUserlist(); //Assuming this function is present in your client controller
})

/*Server Side*/
if(input.action){
//Any code to process
}

P.S. If you're trying to call a function of server script then you can use the above code and call the desired function inside the if block in server side script.

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

Regards,
Shubham

 

View solution in original post

3 REPLIES 3

Shubham_Shinde
Giga Guru

Hello @babarat1 ,

Please refer the solution mentioned in the below post it might solve your problem:
https://www.servicenow.com/community/developer-forum/need-to-remove-close-x-button-from-spmodal/m-p/...

Mark this comment as correct/helpful if it helps you!

 

Regards,

Shubham

Thanks for the reply shubham. I tried however it is not calling the server side action when I add the solution as below

c.deactivateUser=function(name)
{
spModal.confirm("Are you sure you want to deactivate the user? This action will remove all roles from the user and remove the user from this list.").then(function(confirmed) {
if (confirmed) {
c.data.username = name;
c.server.update().then(function(){                                                    
c.data.action='proceed';
c.getUserlist();                                                    
});

}

else
{
spModal.alert("User was not deactivated.");
}
});
 setTimeout(function() {
        var closeButton = this.document.getElementsByClassName('close pull-right');
        //console.log(closeButton.length);
        for (var i = 0; i < closeButton.length; i++) {

            closeButton[i].style.display = 'none';
        }

    }, 0);
}

Hello @babarat1 

If you're trying to pass the data.action to server side script you can do it by using c.server.get({action:"proceed"}), and can access this in server side script by using input.action.
For ex:
/*Client Controller*/
c.server.get({action:"proceed"}).then(function(response){

   c.getUserlist(); //Assuming this function is present in your client controller
})

/*Server Side*/
if(input.action){
//Any code to process
}

P.S. If you're trying to call a function of server script then you can use the above code and call the desired function inside the if block in server side script.

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

Regards,
Shubham