Need to remove Close(X) button from spmodal

Prem13
Tera Contributor

I created a onload catalog client script with the following script(note: not in the widget)

function onLoad() {
  spModal.open({
			title: 'Test.',
			message: "ACknowledge before proceeding",
		
			size: "md",
			buttons: [
				{label:'I Acknowledge', primary: true},
				//{label:'Cancel', primary: false}
			]
		}).then(function(ans){
			if (ans.label == "I Acknowledge"){
				//alert('party');
				
			} 
		});
	
   
}

This is how the popup comes up during catalog item form load.

find_real_file.png

 Need to remove close button(x) which is at right corner.

Note: this is not on widget , the script which i wrote is  onload  catalog client script

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Hi Prem,

I have written this and works:

function onLoad() {

	spModal.open({
		title: 'Test.',
		message: "Acknowledge before proceeding",
		backdrop: 'static',
		size: "md",
		buttons: [
			{label:'I Acknowledge', primary: true},
		]
	}).then(function(ans){
		if (ans.label == "I Acknowledge"){
			//alert('party');

		} 
	});
	var checkExist = setInterval(function() {
		if (top.document.getElementsByClassName('close pull-right')[0]) {
			clearInterval(checkExist);
			var x = top.document.getElementsByClassName('close pull-right')[0];
			x.style.display = "none";
		}
	}, 100); // check every 100ms

}

View solution in original post

11 REPLIES 11

vkachineni
Kilo Sage
Kilo Sage

I don't think you can turn that off.

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Rishabh Jha
Mega Guru

Hi @Prem ,

 

If this is for Service Portal (i.e. https://<your-instance-id>.service-now.com/sp), you can hide it via css.

From the platform navigator, navigate to "Service Portal --> Portals", click on your portal ("Service Portal", if it's for the stock sp). On the portal record, go to the CSS Variables section, and add the below css and it should work.

.modal-header .close {
    display:none;
}

 

Please refer to the screenshots below:

find_real_file.png

 

 

find_real_file.png

 

Thanks & Regards,

Rishabh Jha

Aavenir (https://www.aavenir.com/)

 

 

Hi Rishabh,

 

Actually i wrote the script in catalog client script not in widget's client script.

i want the message to be visible on load of a particular catalog item.

Is it possible to use CSS in catalog client script

 

Hi @Prem ,

The css in my answer above will be applied to the portal, so it doesn't matter where have you defined the spModal.

If you're using the service portal to view the catalog item, it'll work.

 

Thanks & Regards,

Rishabh Jha

Aavenir (https://www.aavenir.com/)