Skip to content

Commit a831662

Browse files
authored
Updated the README.md
1 parent cf6bb1d commit a831662

File tree

1 file changed

+52
-0
lines changed
  • Client-Side Components/UI Actions/Incident Cancellation

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Simplified Incident Cancellation UI Action
2+
3+
## Overview
4+
This enhancement improves the Incident Cancellation UI Action in ServiceNow by replacing an unnecessarily complex GlideModal confirmation structure with a leaner, more maintainable confirmation() dialog.
5+
The new approach enhances code readability, reduces script overhead, and aligns with ServiceNow client–server scripting best practices.
6+
7+
## Problem Statement
8+
The previous incident cancellation UI Action used a GlideModal confirmation window, which:
9+
- Increased code complexity with extra modal creation and rendering steps
10+
- Complicated maintainability with mixed client-server logic
11+
- Provided no additional usability benefit over native browser confirmation
12+
13+
14+
## Proposed Enhancement
15+
The enhancement simplifies the flow by using JavaScript’s built-in confirm() method for quick user confirmation and Added a work note for traceability: “Cancelled this incident.”
16+
17+
## Updated Logic:
18+
- Client-side:
19+
Confirm with confirm() dialog before proceeding.
20+
If confirmed, submit action via gsftSubmit() API to call the server script.
21+
22+
- Server-side:
23+
Update the incident state to "Cancelled" (state = 8).
24+
Add a work note for traceability: “Cancelled this incident.”
25+
Redirect the user back to the current record after completion.
26+
27+
# Benefits
28+
- Simpler and cleaner codebase
29+
- Avoids unnecessary modal logic.
30+
- Better maintainability
31+
- Easier for future developers to modify or extend.
32+
- Improved traceability
33+
- Includes meaningful work notes for auditing.
34+
- Aligned with ServiceNow best practices
35+
- Maintains proper separation of client and server logic following official guidelines.​
36+
37+
## How to Use
38+
39+
- Navigate to System UI → UI Actions in ServiceNow.
40+
- Create a new UI Action on the Incident table.
41+
### Set:
42+
- Action name: Cancel Incident
43+
- Client: Checked
44+
- Onclick: cancelIncident();
45+
- Condition: current.state != 8 && (current.state == '1' || current.state == '2' || current.state == '3');
46+
- Add the provided client and server scripts from the script.js file
47+
- Test the action on an incident form.
48+
49+
## Issue Reference
50+
This contribution is based on the issue titled: `Issue with UI Action Implementation for Simplified Incident Cancellation`
51+
## Issue no: [#2299](https://github.com/ServiceNowDevProgram/code-snippets/issues/2299)
52+
— proposed to improve readability, maintainability, and UX by using a confirmation dialog instead of a GlideModal construct.

0 commit comments

Comments
 (0)