Check the script that updated by is not member of assignment group

Rajavardhini
Tera Contributor

Hi Team,

I am trying to use below script include to check updated by is not member of assignment group but the code is not working. could you please check below.

Script Include:

var Check_customer_update = Class.create();
Check_customer_update.prototype = {
    initialize: function() {},

    check_cust_update: function() {
        var user = current.sys_updated_by;
        var groupName = "CEP UK Team";

        //Get Users sys_id
        var usrGr = new GlideRecord('sys_user');
        if (usrGr.get('user_name', user)) {
            userID = usrGr.sys_id + '';
        } else {
            //we didn't find the user return false

            return false;
        }
        //get Group sys_id
        var grpGr = new GlideRecord('sys_user_group');
        if (grpGr.get('name', groupName)) {
            groupID = grpGr.sys_id + '';
        } else {
            //we didn't find the group return false
            return false;
        }

        //Now see if they are a member of the group

        var grpMbr = new GlideRecord('sys_user_grmember');
        grpMbr.addQuery('user', userID);
        grpMbr.addQuery('group', groupID);
        gr.query();

        if (gr.next()) {
            return true;
        }
        return false;

    },
    type: 'Check_customer_update'
};
 
Business rule:
After Update:
(function executeRule(current, previous /*null when async*/ ) {

   var test= new Check_customer_update().check_cust_update();
 
  gs.addInfoMessage(test+" "+'update');

   

})(current, previous);
 
Could you please help me
1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

You could add some logs to confirm if the user script variable contains the expected value, etc.  You could accomplish this without GlideRecords by using the isMemberOf method either in the BR itself, or in the SI

https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/Glid...