We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

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

You can use Glideajax to update. 

 

for reference 

 

https://[instance].service-now.com/sys_ui_action.do?sys_id=2c2943431f001000dada97c0ed8b70a5

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

You can pass the g_list.Checked() in the script include 

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

 

those things you have to do in script include.

 

someText = this.getParameter('sysparm_sdText').split('\n') //array of sys_ids