Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
30 changes: 30 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,30 @@
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).

/////////////////////////////////////////////////
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.

/////////////////////////////////////////////////
Navigate to system definition > UI pages
Fill the HTML and client script
Submit

//Verification
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 details and set to resolved.

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 @@
function ResolveIncident(sysId) {
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 ResolveIncident('${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>
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'
});
Loading