Not applicable

Thanks Tony!!

what are the results of your debugging\testing? -- In the alert we are getting old value of category

what exactly is\is not working? - if we change category to software in the list and sub category changes to email then record should not submit to server. Script should check is it category is software or not, if yes, then the record should abort.

 

On cell edit Client script:

Field name: Sub category

Script:

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('incidenttTable');
ga.addParam('sysparm_name', 'tablequery');
ga.addParam('sysparm_syssid', sysIDs);
ga.addParam('sysparm_newvalues', newValue);
ga.getXML(myid);

function myid(response) {

var answer = response.responseXML.documentElement.getAttribute("answer");
alert('ramya' + answer);
if (answer == 't1')
if (newValue == 'email')
alert('anns' + answer);
saveAndClose = false;

}
callback(saveAndClose);
}

 

Script Include:

var incidenttTable = Class.create();
incidenttTable.prototype = Object.extendsObject(AbstractAjaxProcessor, {
 
    tablequery: function() {
        var sysid = this.getParameter('sysparm_syssid');
        //var managername = '';
        var empname = new GlideRecord('incident');
        empname.get(sysid);
        empname.query();
        if (empname.next()) {
gs.addInfoMessage('category' + empname.category);
            var state = empname.category;
        }
        var catgory;
        if (state == 'software')
gs.addInfoMessage('category inside' + empname.category);
            catgory = 't1';
        return catgory;
    }
});
 
Thanks in advance!!

Not applicable

Hi @Community Alums ,

You can acheive this without coding.

1. Create Before Insert/Update BR.(It'll work for list editing too)

2.  Filter conditions : category is software

                                    Subcategory is Email

3. Under actions Tab: select Add message & Abort action.

 

Note: Script includes + OncellEdit scripts are not efficeint together , You can user before BR.

Not applicable

Hi Khasim,

Thanks!!

My lead want me to do with On cell Edit.

 

Any idea?

Not applicable

Hi @Community Alums ,

Here are the modified Scripts.

-----Script Include-----

var GetCatagory = Class.create();
GetCatagory.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getCat: function() {
        var sysId = this.getParameter('sysparm_sysId');
        // var subCat = this.getParameter('sysparm_subCat');
        gs.info('sys_id' + sysId);
        var gr = new GlideRecord('incident');
        gr.get(sysId);
        gr.query();
        if (gr.next()) {
            if (gr.category == 'software') {
                return true;
            } else {
                return false;
            }
        }
    },

    type: 'GetCatagory'
});

 

----------Client Script----------

 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
    var saveAndClose;
    //Type appropriate comment here, and begin script below
    var ga = new GlideAjax('GetCatagory');
    ga.addParam('sysparm_name', 'getCat');
    ga.addParam('sysparm_sysId', sysIDs);
    ga.getXML(myid);

    function myid(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");

        if (answer && newValue == 'email') {
            saveAndClose = false;
            alert("Hi! Email can't be selected for category of 'software' try other combination");
            callback(saveAndClose);
        } else {
            saveAndClose = true;
            callback(saveAndClose);
        }
    }
}

Not applicable

@Community Alums ,

I've tested and it's working as expected.

Kindly mark it as a solution.

Khasim.