Ankur Bawiskar
Tera Patron

Hi Stephan,

It seems your UI action code is in custom scope "x_bhhgh"

so GlideRecord in client side is not allowed in scoped application.

you can perform GlideAjax to update the state for those records selected as below

UI Action:

function downloadExcel(){
var checked = g_list.getChecked(); // get's the sys_id of the checked records
var query = "sys_idIN" + checked.toString();
var rows = checked.split(",").length; // rows to be sent to the export function
// this code you can move to script include and go GlideAjax as well

 var ga = new GlideAjax('updateRecords');
    ga.addParam('sysparm_name', 'updateRecorWithValue');
    ga.addParam('sysparm_checked', checked);
    ga.getXML(processResponse);
    
    function processResponse(response) {
    var result = response.responseXML.documentElement.getAttribute("answer");
    }

var view = "Workspace"; // set this to default for columns present in default view for list layout
// set this to empty if you want all the columns present in the list layout including the customized ones.
var dialog = new GwtPollDialog('x_bhhgh_his_cases_his_cases', query, rows, view, 'unload_excel_xlsx');
dialog.execute();
}

Script Include: It should be client callable; ensure it is in your custom scope

var updateRecords = Class.create();
updateRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	updateRecorWithValue: function(){

		var checked = this.getParameter('sysparm_checked');
		var gr = new GlideRecord('x_bhhgh_his_cases_his_cases');
		gr.addQuery('sys_id', 'IN', checked);
		gr.query();
		while(gr.next()){
			gr.state = 6;
			gr.update();
		}
	},

	type: 'updateRecords'
});

Regards
Ankur

 

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader