Hi @Community Alums ,

 

You have a solution now using onCellEdit from Khasim Pathan. I also tried, my version follows

 

 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
	var saveAndClose = true;
	//Type appropriate comment here, and begin script below
	var sysIDstr = sysIDs;
//	alert('sysIDstr = ' + sysIDstr + ', newValue = ' + newValue);
	if (newValue == 'email') {
		var incGA = new GlideAjax('incidentTable');
		incGA.addParam('sysparm_name', 'tablequery');
		/* These don't work for some reason
		incGA.addParam('sysparm_syssid', sysIDstr);
		incGA.addParam('sysparm_newvalues', newValue);
		*/
		incGA.addParam('sysparm_newValue', newValue);
		incGA.addParam('sysparm_sysId', sysIDstr);
		incGA.getXML(myid);
	}

	function myid(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
		var res = JSON.parse(answer);
        if (res.status === 'false') {
			alert(res.message);
			callback(false);
		}
		else
			callback(true);		
	}
}

 

Script include:

 

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

	tablequery: function() {
		obj = {};
		obj.status = 'true';
        obj.message = '';
        var newValue = this.getParameter('sysparm_newValue');
        var sysId = this.getParameter('sysparm_sysId');
//		gs.info("incidentTable: newValue = " + newValue + ", sysId = " + sysId);

		/* doesn't work
        var incID = this.getParameter('sysparam_syssid');
		var incSC = this.getParameter('sysparam_newvalues');
		gs.info('incidentTable: Checking for sys_id =  ' + incID + ', incSC = ' + incSC + '.');
		*/

		var incCategory = '';
        var empname = new GlideRecord('incident');
        empname.addQuery('sys_id', sysId);
        empname.query();
//		gs.info('incidentTable: Found ' + empname.getRowCount() + ' records.');
        if (empname.next()) {
//			gs.info('incidentTable: category: ' + empname.category);
            incCategory = empname.category;
        }
        if ((incCategory == 'software') && (newValue = 'email')) {
//			gs.info('incidentTable: Got invalid combination.');
			obj.status = 'false';
            obj.message = gs.getMessage('Invalid combination of Category: software and Subcategory: email');
            return JSON.stringify(obj);
		}
        return JSON.stringify(obj);
    },
	
    type: 'incidentTable'
});

 

 

I changed some name values, as starting with your versions didn't work. Also see examples of how to debug the client script and script include (Debug lines have been commented out). And from what I can tell, this only works in List view of incident. As I can still select that combination on the incident form. A business rule solution would prevent both. But you can satisfy your lead with the above or what Khasim posted.

View solution in original post