UI List Action to get selected records

mballinger
Mega Guru

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!

1 ACCEPTED SOLUTION

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'
});

View solution in original post

14 REPLIES 14

Pranesh072
Mega Sage
Mega Sage

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

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());
}

this is a client side API 

 

find_real_file.png

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?