diff --git a/Client-Side Components/UI Pages/Resolve Incident UI Page/README.md b/Client-Side Components/UI Pages/Resolve Incident UI Page/README.md new file mode 100644 index 0000000000..d602d54f83 --- /dev/null +++ b/Client-Side Components/UI Pages/Resolve Incident UI Page/README.md @@ -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. + + diff --git a/Client-Side Components/UI Pages/Resolve Incident UI Page/UI_action.js b/Client-Side Components/UI Pages/Resolve Incident UI Page/UI_action.js new file mode 100644 index 0000000000..75e25468f0 --- /dev/null +++ b/Client-Side Components/UI Pages/Resolve Incident UI Page/UI_action.js @@ -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). diff --git a/Client-Side Components/UI Pages/Resolve Incident UI Page/scriptinclude.js b/Client-Side Components/UI Pages/Resolve Incident UI Page/scriptinclude.js new file mode 100644 index 0000000000..963202cdfd --- /dev/null +++ b/Client-Side Components/UI Pages/Resolve Incident UI Page/scriptinclude.js @@ -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' +}); diff --git a/Client-Side Components/UI Pages/Resolve Incident UI Page/ui_page_client.js b/Client-Side Components/UI Pages/Resolve Incident UI Page/ui_page_client.js new file mode 100644 index 0000000000..73fc21706b --- /dev/null +++ b/Client-Side Components/UI Pages/Resolve Incident UI Page/ui_page_client.js @@ -0,0 +1,29 @@ +// 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.trim(); + var resolutionCode = document.getElementById('resolution_code').value.trim(); + if (!rejectionReason || rejectionReason === ' ') { + alert('Resolution Notes is a mandatory field.'); + return false; + } + if (resolutionCode == 'None') { + alert('Resolution Code is a mandatory field.'); + return false; + } + 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; + } diff --git a/Client-Side Components/UI Pages/Resolve Incident UI Page/ui_page_html.html b/Client-Side Components/UI Pages/Resolve Incident UI Page/ui_page_html.html new file mode 100644 index 0000000000..829d4ff1cb --- /dev/null +++ b/Client-Side Components/UI Pages/Resolve Incident UI Page/ui_page_html.html @@ -0,0 +1,27 @@ + + + +
+

+ + +

+

+ + +

+ +
+