Popup alert in service portal

DiNesh77
Tera Contributor

Hi Team ,

I have a requirement that whenever an enduser select a combination of values in Impact and urgency field in service portal,there should be an alert popup stating "This is a high priority issue and will be fixed asap " in bold red text.

For example if an enduser select "All users facing issue " in Impact and "Complete outage" in urgency field,then the above popup alert should appear in the portal.

Any idea how to achieve this?

Thanks

1 ACCEPTED SOLUTION

You will need to create catalog client scripts; one of them should run onChange of the urgency field, and one should run onChange of the impact field.

find_real_file.png

The script below will check the value of both fields and if they match the values in the script it will show the modal.

So copy the code below into the 2 catalog client scripts.

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

	// Get the value of impact and urgency
	var impact = g_form.getValue('impact');
	var urgency = g_form.getValue('urgency');
	var html = '<font color="red" size="4"><p><strong>This is a high priority issue and will be fixed asap</p></strong></font>';

	// If impact and urgency
	if (impact == 'All users facing issue' && urgency == 'Complete outage') {
		// Use spModal to pop the HTML
		if (html) {
			spModal.open({
				title: 'Notice',
				message: html,
				buttons: [
					{label:'OK', primary: true}
				],
			});
		}
	}
}

Hope this helps!

Thanks,
Dan

View solution in original post

11 REPLIES 11

Dan Ellis
Kilo Sage

You could use a client script that runs onchange of those 2 fields. If the script checks the value of the 2 fields it can then display an alert.

var impact = g_form.getValue('impact');
var urgency = g_form.getValue('urgency');

if (impact == "All" && urgency == "Complete Outage") {
  alert("This is a high priority issue and will be fixed asap");
}

Hi Dan,

Will the above script work for service portal ?.

Also would like to know under which table i should write the client scriot you mentioned

 

Thanks

Yes it should work in the Service Portal.
https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/build/service-portal/concept/uns...

Is your form a table form or a catalog item/record producer?

If it is a table form, the client script needs creating against that table.

If it is a catalog item/record producer, you need to create a "catalog client script" for that catalog item/record producer.

I hope that makes sense and helps you out!

Thanks,
Dan

Hi Dan,

Mine is record producer and so i will try the above catalog client script.

Also along with the alert , i need the alert to be in Bold red color.

How shall i achieve it?

Thanks