The CreatorCon Call for Content is officially open! Get started here.

How to covert any priority incident to P1 / P2 if the incident promoted to Major incident.

Rups
Kilo Contributor

Hi Team,

We are implementing Major Incident Workbench functionality. Now the challenge is when the Incident Manager promoting the proposed incident then the incident should be automatically moved either P1 / P2 respectively.

Or while prompting the incident to major incident, we can have a drop down asking incident manager whether the incident can be P1/ P2.

Please help me, how we can proceed. Thanks in advance.

 

Regards,

Rups

1 ACCEPTED SOLUTION

This was achieved via modifying the UI Page "mim_workbench_promote" with the following:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<!-- To use <g:ui_reference/> in this UI page, below are the required JS.
		<g:requires name="scripts/functions.js" includes="true" />
		<g:requires name="scripts/functions_reference.js" includes="true" />
		<g:requires name="scripts/utils.js" includes="true" />
		<g:requires name="scripts/accessibility_tabindex.js" includes="true" />
		<g:requires name="scripts/slushbucket.js" includes="true" />
		<g:requires name="scripts/ac.js" includes="true" />
		<g:requires name="scripts/ac_derived_field_support.js" includes="true" />
		<g:requires name="scripts/popups.js" includes="true" />
		<g:requires name="scripts/classes/AutoComplete.js" includes="true" />
		<g:requires name="scripts/classes/SlushBucket.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXCompleter.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXReferenceControls.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXOtherCompleter.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXReferenceCompleter.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXReferenceCompleterMulti.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXTableCompleter.js" includes="true" />
		<g:requires name="scripts/classes/ajax/AJAXEmailClientCompleter.js" includes="true" />
		<j2:set var="jvar_theme" value="$[gs.getProperty('glide.css.theme.ui16')]"/>
		<g2:requires name="styles/css_includes_doctype.css" includes="true" params="c=$[gs.getCssCacheVersionString()]$[jvar_theme]" />
	-->
	<style>
	.form-horizontal {
		margin-top: 5px;
		margin-bottom: 20px;
	}
	.promote-modal-textarea {
		resize: vertical;
		min-height: 120px
	}
	#dialog_buttons .btn{
		margin-left: 10px;
		padding-left: 15px;
		padding-right: 15px;
	}
	#work-notes-wrapper .required-marker {
		display: inline-block;
	}
</style>
<div class="form-horizontal">
	<div class="form-group" id="work-notes-wrapper">
		<label class="col-sm-2 control-label" for="mim-promote-work-notes">
                    <span mandatory="true" class="required-marker label_description"></span>
			${gs.getMessage('Work notes')}
		</label>
		<div class="col-sm-10">
			<textarea required="true" class="form-control promote-modal-textarea" id="mim-promote-work-notes" type="text" oninput="promoteModal.workNotesOnChange()" onchange="promoteModal.workNotesOnChange()"></textarea>
		</div>
	</div>
	<div class="form-group">
		<label class="col-sm-2 control-label" for="mim-promote-business-impact">${gs.getMessage('Business Impact')}</label>
		<div class="col-sm-10">
			<textarea class="form-control promote-modal-textarea" name="mim-promote-business-impact" id="mim-promote-business-impact"></textarea>
		</div>
	</div>
	
	<!--Below Added to allow priority selection -->
	
	<div class="form-group">
		<label class="col-sm-2 control-label" for="incident-priority">${gs.getMessage('Incident Priority')}</label>
		<div class="col-sm-10">
			<select required="true" id="incident-priority" class="form-control" name="incident-priority">
				<option value="1">${gs.getMessage("P1 - Very High")}</option>
				<option value="2">${gs.getMessage("P2 - High")}</option>
			</select>
		</div>
	</div>	
	
</div>
<div id="dialog_buttons" class="clearfix pull-right">
		<button type="button" class="btn btn-default" onclick="promoteModal.close()" title="${gs.getMessage('Close the dialog')}">${gs.getMessage('Cancel')}</button>
		<button type="button" class="btn btn-primary disabled" aria-disabled="true" id="mim-promote-button" title="${gs.getMessage('Promote to Major Incident')}" onclick="promoteModal.promote()">${gs.getMessage('Promote')}</button>
</div>
</j:jelly>
(function(global) {
	var workNotes = $("mim-promote-work-notes");
	var businessImpact = $("mim-promote-business-impact");
	var workNotesWrapper = $('work-notes-wrapper');
	var promoteBtn = $('mim-promote-button');
	var priority = $('incident-priority');
	workNotes.focus();
	
	if(priority.value == 1){
		var impact = 1;
	} else {
		var impact = 2;
	}
	var dialog = GlideModal.prototype.get("sn_major_inc_mgmt_mim_workbench_promote");
	var currentWorkNotes = dialog.getPreference('WORK_NOTES');
	if(currentWorkNotes) {
		workNotes.value = currentWorkNotes;
		workNotesOnChange();
	}
	var currentBusinessImpact = dialog.getPreference('BUSINESS_IMPACT');
	if(currentBusinessImpact)
		businessImpact.value = currentBusinessImpact;
	function _debounce(func, wait, immediate) {
		var timeout;
		return function() {
			var context = this,
				args = arguments;
			var later = function() {
				timeout = null;
				if (!immediate) func.apply(context, args);
			};
			var callNow = immediate && !timeout;
			clearTimeout(timeout);
			timeout = setTimeout(later, wait);
			if (callNow) func.apply(context, args);
		};
	}

	function workNotesOnChange() {
		if (!workNotes.value.trim()) {
			workNotesWrapper.removeClassName('is-filled');
			promoteBtn.addClassName('disabled');
			promoteBtn.writeAttribute('aria-disabled', true);
		} else {
			workNotesWrapper.addClassName('is-filled');
			promoteBtn.removeClassName('disabled');
			promoteBtn.writeAttribute('aria-disabled', false);
		}
	}

	function _promoteRestCall(record) {
		var dfd = $j.Deferred();
		var api = '/api/sn_major_inc_mgmt/mim/actions/' + window.NOW.MAJOR_INCIDENT_WORKBENCH.sys_id;
		var data = {
			action: 'PROMOTE',
			record: record
		};
		$j.ajax({
			type: 'POST',
			url: api,
			data: JSON.stringify(data),
			success: function(data) {
				dfd.resolve(data);
			},
			error: function() {
				dfd.reject();
			},
			contentType: "application/json",
			dataType: 'json'
		});
		return dfd.promise();
	}

	function promote() {
		getMessage("Promoted to a major incident", function(msg) {
			var updateWorkNotes = msg + "\n" + workNotes.value.trim();
			if (!promoteBtn.hasClassName('disabled')) {
				if (window.NOW.MAJOR_INCIDENT_WORKBENCH) {
					var record = {};
					record.work_notes = updateWorkNotes;
					record.business_impact = businessImpact.value;
					record.impact = impact;
					record.urgency = "2";
					_promoteRestCall(record).then(function() {
						dialog.setPreference('reload', true);
						close();
					});
				} else {
					//When UI Page is rendered from Form UI Action
					g_form.getControl('work_notes').value = updateWorkNotes;
					g_form.setValue('business_impact', businessImpact.value);
					g_form.setValue('impact',impact);
					g_form.setValue('urgency',"1");
					GlideModal.prototype.get('sn_major_inc_mgmt_mim_workbench_promote').destroy();
					gsftSubmit(null, g_form.getFormElement(), 'sysverb_mim_accept');
				}
			}
		});
	}

	function close() {
		dialog.destroy();
	}
	global.promoteModal = {
		promote: promote,
		close: close,
		workNotesOnChange: _debounce(workNotesOnChange, 200) // Only execute when left idle for 200 ms
	};
})(window);

 

View solution in original post

11 REPLIES 11

Kieran Anson
Kilo Patron

Hi,

On your first request, are you wanting the reverse of a trigger rule? Trigger rules usually act on the content of the incident form to decide if the record should be proposed. Usually this is if the incident is a P1 or P2, mark as a proposal.

Are you wanting it so a user can manually change the dropdown field 'major incident state' and if they do so, the priority is auto set to a P1 or P2?

Hi Kieran,

 

Thanks for the response, to be more clear.

Firstly, using trigger rules pushing to promotion of incident to Major Incident.

Our request is, if P3/P4 incident is promoted to Major incident,  upon promoting it should ask with P1/P2 doprdown to incident manager to move further with major incident and priority change to p1/p2 from p3/p4. Is this possible in this module.

 

Please assist

Thanks Rups,

Is this promotion via the "Promote to Major Incident" UI Action?

 

find_real_file.png

Thanks Kieran, this is exactly what we are looking for. can you please help me how to achieve this.

Is this will promote P3/P4 incident to P1/P2, if incident manager select while promoting to major incident? If yes kindly help me how to achieve this

 

Thanks in advance,

Rups