- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2021 08:42 AM
Hello,
I am struggling to find how to capture selected records in a List UI Action on the incident table. What I need to be able to do is get all the selected incident numbers (this needs to work for select all as well).
Any ideas?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2021 09:59 AM
I updated the script, there were some syntax issues
function showConfirmDialog() {
var entries = g_list.getChecked();
if (!entries || entries.length == 0)
return;
var ga = new GlideAjax('GetIncidentNumber');
ga.addParam('sysparm_name', 'getIncident');
ga.addParam('sysparm_entry_ids', entries);
ga.getXML(getRequiredInc);
function getRequiredInc(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert("Some alert to test if it works: " + answer);
}
}
var GetIncidentNumber = Class.create();
GetIncidentNumber.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getIncident: function() {
var array = [];
var entries = this.getParameter('sysparm_entry_ids');
var sysIds = entries.split(",");
var gr = new GlideRecord('incident');
gr.addQuery('sys_id','IN',entries);
gr.query();
while (gr.next()) {
array.push(gr.getValue("number"));
}
//var createList = array.join(',');
return array.toString();
},
type: 'GetIncidentNumber'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2021 10:19 AM
You can use Glideajax to update.
for reference
https://[instance].service-now.com/sys_ui_action.do?sys_id=2c2943431f001000dada97c0ed8b70a5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 10:28 AM
Thanks for providing this example. In the script include, how can I query on the sys_ids and return the number? I am trying to capture an array of Incident #'s of the selected checkboxes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 11:05 AM
You can pass the g_list.Checked() in the script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 11:28 AM
Yes I see that in the script include, but how do I print out the Incident number of each sys_id? I've already passed g_list.Checked(), now am unsure of how to get the different details from the sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 11:53 AM
those things you have to do in script include.
someText = this.getParameter('sysparm_sdText').split('\n') //array of sys_ids