- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 08:55 AM
Hello,
Please, How to create a button that close many incidents (checked incidents) at once (if I am an agent of the helpdesk) ? I followed this article but it didn't work : https://www.servicenow.com/docs/bundle/yokohama-it-service-management/page/product/incident-manageme...
So, to explain more : if I am an agent , I want to check some incidents in ALL>Incidents>open and click on a button to close them all at one time :
Thanks,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 02:41 AM
Hello @yasserbouat,
I have tried to create a small POC , hope it helps you to resolve your issue.
Step 1: Create a UI Action for incident table.
Add below code
function resolveSelected() {
var selectedIncidents = g_list.getChecked();
if (!selectedIncidents) {
alert("No Incidents selected!");
return;
} else {
var glideAjax = new GlideAjax("IncidentUtils3");
glideAjax.addParam("sysparm_name", "closeIncidents");
glideAjax.addParam("sysparm_incidents", selectedIncidents);
glideAjax.addParam("sysparm_closeCode", "Resolved by caller");
glideAjax.addParam("sysparm_closeNote", 'Resolved!');
glideAjax.getXMLAnswer(function(answer) {
if(answer =='true'){
top.location.reload();
}
});
}
}
Step 2: Create a Script Include
Add below code
closeIncidents: function() {
var selectedIncidents = this.getParameter("sysparm_incidents");
var notes = this.getParameter("sysparm_closeNote");
var code = this.getParameter("sysparm_closeCode");
var incidentGr = new GlideRecord('incident');
incidentGr.addQuery('sys_id', 'IN', selectedIncidents);
incidentGr.query();
while (incidentGr.next()) {
incidentGr.setValue('state', 7);
incidentGr.setValue('close_notes', notes);
incidentGr.setValue('close_code', code);
incidentGr.update();
}
return true;
},
The above code will close all the selected incidents with a static Resolution code and Resolution Notes mentioned in the code.
Note: Make sure you add appropriate access control to script include, else it wont get called.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 02:42 AM
that's OOB behavior.
the data policy is blocking the update since you didn't fill in the mandatory fields.
Populate the Resolution code and Resolution Notes field when the screen appears after clicking Update selected
Then the data policy won't block
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
02-27-2025 02:41 AM
Hello @yasserbouat,
I have tried to create a small POC , hope it helps you to resolve your issue.
Step 1: Create a UI Action for incident table.
Add below code
function resolveSelected() {
var selectedIncidents = g_list.getChecked();
if (!selectedIncidents) {
alert("No Incidents selected!");
return;
} else {
var glideAjax = new GlideAjax("IncidentUtils3");
glideAjax.addParam("sysparm_name", "closeIncidents");
glideAjax.addParam("sysparm_incidents", selectedIncidents);
glideAjax.addParam("sysparm_closeCode", "Resolved by caller");
glideAjax.addParam("sysparm_closeNote", 'Resolved!');
glideAjax.getXMLAnswer(function(answer) {
if(answer =='true'){
top.location.reload();
}
});
}
}
Step 2: Create a Script Include
Add below code
closeIncidents: function() {
var selectedIncidents = this.getParameter("sysparm_incidents");
var notes = this.getParameter("sysparm_closeNote");
var code = this.getParameter("sysparm_closeCode");
var incidentGr = new GlideRecord('incident');
incidentGr.addQuery('sys_id', 'IN', selectedIncidents);
incidentGr.query();
while (incidentGr.next()) {
incidentGr.setValue('state', 7);
incidentGr.setValue('close_notes', notes);
incidentGr.setValue('close_code', code);
incidentGr.update();
}
return true;
},
The above code will close all the selected incidents with a static Resolution code and Resolution Notes mentioned in the code.
Note: Make sure you add appropriate access control to script include, else it wont get called.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 06:39 AM
Hello @Community Alums
Thanks very much : it worked perfectly 🙏
If I want to learn to do this like you did , what should I learn ? can you please inbox me some ressources / tutorials / roadmap ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 07:33 AM
Hi @yasserbouat,
Thank you for accepting my solution 🙂
Refer below link for learning stuff, it has all the stuff which will help to understand ServiceNow better.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 04:21 AM
but If the need is to create a button that allows the agent to close many selected incidents at once : does someone have an idea ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2025 04:37 AM
you will have to use a custom button for this which is of type List banner
sharing link here
Bulk List Editing Tips and Tricks: showQuickForm
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