Propose Major Incident UI Page Client Script

Emelia Langa1
Kilo Explorer

Good Day, 

We enabled ServiceNow's major incident plugin and notice that the "Propose Major Incident" functionality brings up a pop-up to update the Business Impact and Work Notes.

We have changed this to instead display the Incident Impact and Urgency fields as well as the Work Notes. This is to ensure that the support person proposing the major incident is reviewing and updating the Impact and Urgency. This works well, however, with our focus to only have Priority 1 and Priority 2 incidents proposed as a major incident, we are not able to limit the Impact and Urgency drop-down selections to include only the selections that calculate to a Priority 1 & Priority 2.

We need assistance and guidance on how to limit the Impact and Urgency drop-down selections which are displayed on the pop-up to only show specific selections and make this fiels mandatory.

We tried using client script and UI Page client script but both scripts are not working.

 

Regards;

Emelia Langa

1 ACCEPTED SOLUTION

Took me a while, but I think I have it.

Change this:

if(!config.workspace) {
			dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_propose");

          var currentWorkNotes = dialog.getPreference('WORK_NOTES');
          if(currentWorkNotes) {
              workNotes.value = currentWorkNotes;
              workNotesOnChange();
          }
          var currentImpact = dialog.getPreference('IMPACT');
          if(currentImpact)
              Impact.value = currentImpact;
			var currentUrgency = dialog.getPreference('URGENCY');
          if(currentUrgency)
              Urgency.value = currentUrgency;
        }

 

To this:

if (!config.workspace) {
			dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_propose");

			var currentWorkNotes = dialog.getPreference('WORK_NOTES');
			if (currentWorkNotes) {
				workNotes.value = currentWorkNotes;
				workNotesOnChange();
			}
			var currentImpact = dialog.getPreference('IMPACT');
			if (currentImpact) {
				var impactValuesToRemove = ['5', '4', '3'];//remove impact value 3,4,5 
				Impact.value = currentImpact;
				for (var i = 0; i < Impact.length; i++) {
					if (impactValuesToRemove.indexOf(Impact.options[i].value) != -1)
						Impact.remove(i);
				}
			}
			var currentUrgency = dialog.getPreference('URGENCY');
			if (currentUrgency) {
				var urgencyValuesToRemove = ['5', '4', '3'];//remove impact value 3,4,5 
				Urgency.value = currentUrgency;
				for (var i = 0; i < Urgency.length; i++) {
					if (urgencyValuesToRemove.indexOf(Urgency.options[i].value) != -1)
						Urgency.remove(i);
				}
			}
		}

View solution in original post

7 REPLIES 7

Willem
Giga Sage
Giga Sage

Can you share the code you already have and put in comments on what you tried but is not working? That way we can best help you.

Hi Willem, 

See attached screenshot and XML of what we tried. 

 

Thank you in advance. 

 

Regards, 

Emelia 

Can you try changing the function 'propose' to:

function propose() {
			if (!proposeBtn.hasClassName('disabled')) {
				var msg = getMessage("Proposed as major incident candidate");
				var notes = workNotes.value.trim();
				var bi =impact.value.trim();
				var be = urgency.value.trim();
				g_form.removeOption('impact', '3');
				g_form.removeOption('impact', '4');
				g_form.removeOption('impact', '5');
				g_form.removeOption('urgency', '3');
				g_form.removeOption('urgency', '4');
				g_form.removeOption('urgency', '5');
				if(!config.workspace) {
					g_form.getControl('work_notes').value = msg + "\n" + notes;
					if (impact.value)
						g_form.setValue('impact', bi);
					if (urgency.value)
						g_form.setValue('urgency', be);
					close();
					gsftSubmit(null, g_form.getFormElement(), 'sysverb_mim_propose');
				}else {
					iframeMsgHelper.confirm({
						msg: msg,
						workNotes: notes,
						impact: bi,
						urgency:be
					});
				}
			}
		}

Took me a while, but I think I have it.

Change this:

if(!config.workspace) {
			dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_propose");

          var currentWorkNotes = dialog.getPreference('WORK_NOTES');
          if(currentWorkNotes) {
              workNotes.value = currentWorkNotes;
              workNotesOnChange();
          }
          var currentImpact = dialog.getPreference('IMPACT');
          if(currentImpact)
              Impact.value = currentImpact;
			var currentUrgency = dialog.getPreference('URGENCY');
          if(currentUrgency)
              Urgency.value = currentUrgency;
        }

 

To this:

if (!config.workspace) {
			dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_propose");

			var currentWorkNotes = dialog.getPreference('WORK_NOTES');
			if (currentWorkNotes) {
				workNotes.value = currentWorkNotes;
				workNotesOnChange();
			}
			var currentImpact = dialog.getPreference('IMPACT');
			if (currentImpact) {
				var impactValuesToRemove = ['5', '4', '3'];//remove impact value 3,4,5 
				Impact.value = currentImpact;
				for (var i = 0; i < Impact.length; i++) {
					if (impactValuesToRemove.indexOf(Impact.options[i].value) != -1)
						Impact.remove(i);
				}
			}
			var currentUrgency = dialog.getPreference('URGENCY');
			if (currentUrgency) {
				var urgencyValuesToRemove = ['5', '4', '3'];//remove impact value 3,4,5 
				Urgency.value = currentUrgency;
				for (var i = 0; i < Urgency.length; i++) {
					if (urgencyValuesToRemove.indexOf(Urgency.options[i].value) != -1)
						Urgency.remove(i);
				}
			}
		}