Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions Client-Side Components/UI Pages/Resolve Incident UI Page/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Use Case:

Everytime user try to resolve the incident, the resolution codes and resolution notes are mandatory to be entered as it hidden in tabs,Since it is mandatory fields. So to ease the process we introduced a custom UI action will prompt the user
to enter resolution notes and resolution codes and automatically set the state to Resolved.

How it Works:

Navigate the Incident form and make sure the incident is not closed or active is false.
Click Resolve Incident UI action, it will open an modal with asking resolution notes and resolution code.
Provide the details and submit. incident is updated with above Resolution notes and codes and set state to be Resolved.


Below Action Need to Performed:

1.Create UI action:

Navigate to System UI > UI Actions.
Create a new UI Action with the following details:
Name: Resolve Incident (or a descriptive name of your choice).
Table: Incident [incident].
Action name: resolve_incident_action (must be a unique, server-safe name).
Order: A number that determines the position of the button on the form.
Client: Check this box. This is crucial for running client-side JavaScript.
Form button: Check this box to display it on the form.
Onclick: ResolveIncident() (This must match the function name).
Condition: Set a condition to control when the button is visible (e.g., current.active == true).

2.Create Script Include:

Navigate to System Definition > Script Includes.
Click New.
Fill in the form:
Name: ResolutionProcessor
Client callable: Check the box.
Copy the provided script into the Script field.
Click Submit.

3.Create UI page:

Navigate to System Definition > UI pages
Fill the HTML and client script.
Click Submit.


Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function ResolveIncident() {
var dialog = new GlideModal("resolve_incident");
dialog.setTitle("Resolve Incident");
dialog.setPreference('sysparm_record_id', g_form.getUniqueValue());
dialog.render(); //Open the dialog
}


// Navigate to System UI > UI Actions.
// Create a new UI Action with the following details:
// Name: Resolve Incident (or a descriptive name of your choice).
// Table: Incident [incident].
// Action name: resolve_incident_action (must be a unique, server-safe name).
// Order: A number that determines the position of the button on the form.
// Client: Check this box. This is crucial for running client-side JavaScript.
// Form button: Check this box to display it on the form.
// Onclick: ResolveIncident() (This must match the function name).
// Condition: Set a condition to control when the button is visible (e.g., current.active == true).
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var ResolutionProcessor = Class.create();
ResolutionProcessor.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
updateRecord: function() {
var recordId = this.getParameter('sysparm_record_id');
var reason = this.getParameter('sysparm_reason');
var resolution = this.getParameter('sysparm_resolution');
gs.info("Updating record " + recordId + " with reason: " + reason + " and resolution: " + resolution);
var grinc = new GlideRecord('incident');
if (grinc.get(recordId)) {
grinc.close_code = resolution;
grinc.close_notes = reason;
grinc.state = '6'; //set to resolved
grinc.update();
} else {
gs.error('No Record found for ' + recordId);
}
},
type: 'ResolutionProcessor'
});
Copy link
Contributor

@rohi-v rohi-v Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention as a comment in below code on where below code will be used.

I can see 2 seperate codes for UI Action, keep the necessary one and remove the file which is not requ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention as a comment in below code on where below code will be used.

I can see 2 seperate codes for UI Action, keep the necessary one and remove the file which is not required.

@rohi-v i dont see any two files which one you are referring
image

Copy link
Contributor

@rohi-v rohi-v Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's updated now. Thank you.

there were 2 codes so specifying which one to use where will help because the method name 'ResolveIncident()' is same in both the scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's updated now. Thank you.

there were 2 codes so specifying which one to use where will help because the method name 'ResolveIncident()' is same in both the scripts.

@rohi-v updated the function name.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Below code will be used in client script of UI page as mentioned in README.md file

function ResolveIncidentOnsubmit(sysId) { //This function is called in UI page HTML section When user clicks the Submit button
var rejectionReason = document.getElementById('resolution_reason').value;
var resolutionCode = document.getElementById('resolution_code').value;
var ga = new GlideAjax('ResolutionProcessor');
ga.addParam('sysparm_name', 'updateRecord');
ga.addParam('sysparm_record_id', sysId);
ga.addParam('sysparm_reason', rejectionReason);
ga.addParam('sysparm_resolution', resolutionCode);
ga.getXML(handleSuccessfulSubmit);
GlideDialogWindow.get().destroy();
return false;
function handleSuccessfulSubmit(answer) {
window.location.reload();
}
}
function closeDialog() {
GlideDialogWindow.get().destroy();
return false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_sys_id" expression="RP.getWindowProperties().get('sysparm_record_id')" />
<div>
<p>
<label for="resolution_reason">Enter the Resolution Notes</label>
<textarea id="resolution_reason" name="resolution_reason" class="form-control" rows="4" cols="80"></textarea>
</p>
<p>
<label for="resolution_code">Select the Resolution Code</label>
<select id="resolution_code" name="resolution_code" class="form-control">
<option value="No resolution provided">No resolution provided</option>
<option value="Resolved by request">Resolved by request</option>
<option value="Resolved by caller">Resolved by caller</option>
<option value="Solution provided">Solution provided</option>
<option value="Duplicate">Duplicate</option>
<option value="Resolved by change">Resolved by change</option>
<option value="Workaround provided">Workaround provided</option>
<option value="Known error">Known error</option>
<option value="Resolved by problem">Resolved by problem</option>
<option value="User error">User error</option>
</select>
</p>
<g:dialog_buttons_ok_cancel ok_text="${gs.getMessage('Submit')}" ok_title="${gs.getMessage('Submit')}" ok="return ResolveIncidentOnsubmit('${jvar_sys_id}');" ok_style_class="btn btn-primary" cancel_text="${gs.getMessage('Cancel')}" cancel_title="${gs.getMessage('Cancel')}" cancel="return closeDialog(); disable" />
</div>
</j:jelly>