I need to create UI action on the Incident List in service operation Workspace
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 01:54 AM
Hi All,
Actually i have requirement that need to create a Ui action "Next Incident" on the "Unassigned i group list"
- When I click on the Next Incident button from the "Unassigned in my Group" Incident List in the Service Operations Workspace,
- The next valid incident is assigned to me, following the logic of:
- The Incident in the list which has the least remaining business time on it's In Progress response SLA,
- If no Incidents have In Progress Response SLAs, then the Incident in the list which has the least remaining business time on it's Resolution SLA.
Please help me to achieve this
Thanks
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 02:07 AM
sorry your requirement is not clear.
can you share what did you start with and where are you stuck?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 07:25 PM
Actually in the Sow , in incident list "Unassigned i group list", i need a ui action called "Next Incident"
when i click on that ui action, its needs to assign the incident based on above criteria which i mentioned
Thanks
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 07:54 PM
you can create a list banner button on Incident and have logic within it for those 2 points.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 07:37 PM
Hi Deepika
Create a ui action and write below code in workspace
function nextIncident() {
// Get current user
var currentUser = gs.getUserID();
// Get user's groups
var userGroups = [];
var groupGR = new GlideRecord('sys_user_grmember');
groupGR.addQuery('user', currentUser);
groupGR.query();
while (groupGR.next()) {
userGroups.push(groupGR.group.toString());
}
// Query unassigned incidents in user's groups
var incGr = new GlideRecord('incident');
incGr.addQuery('assignment_group', 'IN', userGroups.join(','));
incGr.addNullQuery('assigned_to');
incGr.addQuery('state', '1'); // New state
incGr.query();
var leastTimeIncident = null;
var leastRemainingTime = -1;
// First check for Response SLA
while (incGr.next()) {
var taskSLA = new TaskSLA(incGr);
var responseSLA = taskSLA.findSLA('response_time');
if (responseSLA && responseSLA.business_time_left > 0) {
if (leastRemainingTime == -1 || responseSLA.business_time_left < leastRemainingTime) {
leastRemainingTime = responseSLA.business_time_left;
leastTimeIncident = incGr;
}
}
}
// If no incident found with Response SLA, check Resolution SLA
if (!leastTimeIncident) {
incGr.query();
while (incGr.next()) {
var taskSLA = new TaskSLA(incGr);
var resolutionSLA = taskSLA.findSLA('resolution_time');
if (resolutionSLA && resolutionSLA.business_time_left > 0) {
if (leastRemainingTime == -1 || resolutionSLA.business_time_left < leastRemainingTime) {
leastRemainingTime = resolutionSLA.business_time_left;
leastTimeIncident = incGr;
}
}
}
}
// Assign incident if found
if (leastTimeIncident) {
leastTimeIncident.assigned_to = currentUser;
leastTimeIncident.state = 2; // In Progress
leastTimeIncident.update();
gs.addInfoMessage('Incident ' + leastTimeIncident.number + ' has been assigned to you.');
action.setRedirectURL(current);
} else {
gs.addInfoMessage('No unassigned incidents found in your groups.');
}
}
nextIncident();