Major Incident Management (MIM) - Edit the Resolve button modal popup window to account for custom fields
Do you need to require an additional field for Incident resolution but are not sure how to edit the Major Incident workbench Resolve button to account for this? If so, you are at the right place, and I hope this helps you!
**As a quick caveat, this does involve editing an OOB UI Page and at least some familiarity with editing or creating UI Pages in ServiceNow. This customization should also be monitored with each release to ensure you are consolidating code if new platform changes to the Major Incident Management plugin come out.
**NOTE: Please see the comments on this post for additional information on reference fields, dependent fields, etc
What is the issue we are trying to solve?
You have a custom field or existing field that is NOT used OOB for resolution in the Incident Management process....and you want to make this field required for resolution.
There is no issue with making this change in the Native UI & Agent Workspace as you can modify Client Scripts, UI Policies, and Business Rules easily to make sure the Native UI & Agent Workspace comply with your new requirement.....I am NOT going to cover that in this post.
However, there IS an issue if you use the Major Incident Management plugin as the Resolve button on the Major Incident Management workbench is a custom modal controlled by a UI Page and must be edited.
See the example below.
In this first image, you can see I added a custom field "Custom Resolution Code Field" and made it required for resolution via the the OOB UI Policy.
However, in this second image you can see in the Major Incident Mgmt Workbench, the Resolve action is managed separately, so we need a way to add this custom field.
How do we solve this?
We need to add the new field in the Resolve modal windows. Below are the steps to do it.
1. Locate the "mim_workbench_resolve" UI Page under System UI -> UI Pages. All work will take place here and in a custom script include we create
2. Add the field to the HTML (Client Side UI) code in the UI Page at the location you would like. In this case I am adding the below code in between the other two fields. I am highlighting where I make syntax changes that you will need to replace with your own field name or notation
3. Add the following pieces of code to the UI Page Client Script. I am adding an explanation of each piece of code
//Not in a specific function - part of the initial variable definition (copy of lines 4-5)
//Allows the client script to detect the new field for further use later on in the script
A
var resolutionCustomField = $("mim-resolution-custom-field");
var resolutionCustomFieldWrapper = $("resolution-custom-field-wrapper");
//New function that will function on change of the new field (copy of 'resolutionCodeOnChange' function)
B
function resolutionCustomFieldOnChange() {
if(!resolutionCustomField.value)
resolutionCustomFieldWrapper.removeClassName('is-filled');
else
resolutionCustomFieldWrapper.addClassName('is-filled');
enableResolveBtn();
}
//Editing the 'enableResolveBtn' function so the Resolve button is enabled once all of the fields are filled in
//The only code being changed here is the first IF statement (highlighting the additional code)
C
function enableResolveBtn(){
if(resolutionNotes.value.trim() && resolutionCode.value && resolutionCustomField.value) {
resolveBtn.removeClassName('disabled');
resolveBtn.writeAttribute('aria-disabled', false);
} else {
resolveBtn.addClassName('disabled');
resolveBtn.writeAttribute('aria-disabled', true);
}
}
//Editing the 'resolve' function so the new field value gets saved to the Incident record
//Highlighting the added code - you should insert the name of your custom field
D
function resolve() {
if (!resolveBtn.hasClassName('disabled')) {
var record = {};
record.close_notes = resolutionNotes.value.trim();
record.close_code = resolutionCode.value;
//CUSTOM Code Start
record.u_custom_resolution_code_field = resolutionCustomField.value;
//CUSTOM Code End
_resolveRestCall(record).then(function() {
dialog.setPreference('reload', true);
close();
});
}
}
https://www.servicenow.com/community/itsm-articles/major-incident-management-mim-edit-the-resolve-button-modal/ta-p/2307872