- 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 08:49 AM
use g_list in the ui action
g_list.getChecked(); //comma separated sysIDs
https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideListV3API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2021 09:05 AM
How can I take the sys_id from the client and use in a GlideRecord? I want to take the selected sys_ids and update a record on another table using the number from the sys_ids
function selectedRecords() {
alert(g_list.getChecked());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2021 09:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2021 09:39 AM
Yes I made this change not realizing it was client side (comment above). In the same UI Action, how can I update a record to another table?
***EDIT***
How can I update a record with the selected records on a different table?