Alert option on Client Controller Portal widget

DPrasna
Tera Contributor

Hello All,

I currently have an alert message that opens up for confirmation of deactivating a User.

However it shows up the message with instance URL as shown below

DPrasna_0-1674051463887.png

However I do not want to popup the message that way with the URL. And here is my script below. Can someone please help to achieve this from a different pov.

 

Client

 

c.deactivateUser=function(name)
	{
		//alert("User will be deactivated");
		if(confirm("Are you sure you want to deactivate the user?") == true){
			c.data.username = name;
			c.server.update().then(function(){                                                    
				c.data.action='proceed';                                                    
			});	
		} else {
			alert("User was not deactivated.");
		}
	}

 

Also I need cancel option which is not available currently

HTML

 

<li><a href="javascript&colon;void(0);" ng-click="c.deactivateUser(user.sys_id)">Deactivate User</a></li>

 

 

TIA/.

@Ankur Bawiskar @jaheerhattiwale @Community Alums @RaghavSh @Mark Roethof 

6 REPLIES 6

Sagar Pagar
Tera Patron

Hi @DPrasna,

 

Try with this updated client controller scripts -

c.deactivateUser = function(name) {
	//alert("User will be deactivated");
	c.data.username = name;
	c.server.update().then(function() {
		c.data.action = 'proceed';
	});
}

 

Thanks,
Sagar Pagar

The world works with ServiceNow

jaheerhattiwale
Mega Sage
Mega Sage

@DPrasna You can use spModal.open().

 

please check below link:

https://www.servicenow.com/community/developer-blog/servicenow-spmoldal-servicenow-enhance-your-cata...

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Ankur Bawiskar
Tera Patron
Tera Patron

@DPrasna 

as mentioned by other member you can use spModal.open()

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

c.deactivateUser=function(name)
	{
		//alert("User will be deactivated");
		if(confirm("Are you sure you want to deactivate the user?") == true){
			c.data.username = name;
			c.server.update().then(function(){                                                    
				c.data.action='proceed';                                                    
			});	
		} else {
			alert("User was not deactivated.");
		}
	}

how to use spmodel in the above case? with ok and cancel options