Skip to content

Commit 823e311

Browse files
authored
Create Prompt for Creating a UI Action to Reopen Resolved Incidents (#55)
This repository contains a UI Action developed in ServiceNow to allow users to reopen resolved incidents. The action is restricted to users with specific roles.
1 parent ec5c1e8 commit 823e311

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
### Prompt for Creating a UI Action to Reopen Resolved Incidents
2+
3+
**Prompt:** Develop a UI Action that enables users to reopen incidents that have been marked as "Resolved." This action should be visible only to users with specific roles (e.g., `itil`).
4+
5+
**Structure:** Outline the steps to create the UI Action, including the script logic for reopening incidents and the conditions for visibility based on user roles.
6+
7+
---
8+
9+
### Expected Output:
10+
11+
1. **Navigate to UI Actions:**
12+
- Go to **System Definition > UI Actions** in ServiceNow.
13+
- Click on **New** to create a new UI Action.
14+
15+
2. **Configure UI Action Properties:**
16+
- **Name:** Reopen Incident
17+
- **Table:** Incident [incident]
18+
- **Active:** True
19+
- **Show insert:** False (only for updates)
20+
- **Show update:** True (to allow updates)
21+
- **Form button:** True (to appear as a button on the form)
22+
23+
3. **Set Conditions:**
24+
- **Condition:**
25+
```javascript
26+
current.state == 'Resolved' && (gs.hasRole('itil') || gs.hasRole('admin'))
27+
```
28+
- This condition ensures that the action only appears for resolved incidents and is accessible to users with the `itil` or `admin` roles.
29+
30+
4. **Script Logic:**
31+
- Add the following script in the **Script** field:
32+
33+
```javascript
34+
// Check if the current user has the appropriate role
35+
if (gs.hasRole('itil') || gs.hasRole('admin')) {
36+
// Reopen the incident
37+
current.state = 'In Progress';
38+
current.update(); // Save the change
39+
gs.addInfoMessage('Incident ' + current.number + ' has been reopened.');
40+
} else {
41+
gs.addErrorMessage('You do not have permission to reopen this incident.');
42+
}
43+
```
44+
45+
5. **User Experience:**
46+
- Ensure that the UI Action button is clearly labeled "Reopen Incident."
47+
- Test the action to confirm it only appears for users with the specified roles and that it correctly changes the incident's state.
48+
49+
6. **Testing:**
50+
- Log in as a user with the `itil` role and verify that the "Reopen Incident" button is visible on resolved incidents.
51+
- Log in as a user without the role and confirm that the button is not visible.
52+
- Test the functionality by reopening a resolved incident and checking if the state changes to "In Progress."
53+
54+
7. **Documentation:**
55+
- Document the UI Action in the ServiceNow application documentation, including its purpose and usage instructions for end users.
56+
57+
---

0 commit comments

Comments
 (0)