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

Hi Dan,

It does not work as expected,i am still seeing english popup.

Can i have a deep insight on this ?

Also would like to know why two records should be created in message table?

Thanks

You need a UI Message record for each language that you want the language to be displayed in. So if you want the language displayed in English, French, or Dutch you would need 3 records.

If a user has their language preference on their user profile set to French, ServiceNow will retrieve the French UI Message record, and if a user had their language set to Dutch ServiceNow would retrieve the Dutch version.

I have tested this when being logged in as 2 different users, one of which had language set to French.

Change the Catalog Client Script code to be:

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');
	
	// If impact and urgency match the values
	if (impact == 'All users facing issue' && urgency == 'Complete outage') {

		// Get the message in the users language
		getMessage("high_priority_issue", function(msg){
			var html = '<font color="red" size="4"><p><strong>' + msg + '</p></strong></font>';

			// Use spModal to show the message
			if (html) {
				spModal.open({
					title: 'Notice',
					message: html,
					buttons: [
						{label:'OK', primary: true}
					],
				});
			}
		});
	}
}

UI Message Records:

find_real_file.png

Alert when the users language preference is French:

find_real_file.png