Exclude groups that does not starts with ECAB or Knowledge

Apoorva D
Tera Contributor

Hi All,

 

I am trying to exclude groups that start with ECAB or KNOWLEDGE; it should also exclude groups that have the 'mic' group type. So i have tried with the background script with Not operator like below code.

 

 var query = "nameSTARTSWITHECAB^ORnameSTARTSWITHKNOWLEDGE^ORtypeLIKE704093f22b08224072751cf405da1599";
var rev ="!" + query;
var l1 = new GlideRecord('sys_user_group');
l1.addEncodedQuery(rev);
l1.addQuery('active', true);
l1.query();
while(l1.next()){
    gs.print(l1.getRowCount());
    gs.print(l1.name);
}
 
But this script is printing records which has ECAB or Knowledge, Could you please provide me the input.
conditions : Group does not start with ECAB or Group does not start with Knowledge and Type is not Mic
 
 
Thanks,
Apoorva
2 REPLIES 2

Manmohan K
Tera Sage

Hi @Apoorva D 

 

Check with below script. This will work !!

 

var l1 = new GlideRecord('sys_user_group');
l1.addQuery('name', 'NOT LIKE', 'ECAB%');
l1.addQuery('name', 'NOT LIKE', 'KNOWLEDGE%');
l1.addEncodedQuery('typeNOT LIKE704093f22b08224072751cf405da1599');
l1.addQuery('active', true);
l1.query();
 gs.print(l1.getRowCount());
while(l1.next()){
     gs.print(l1.name);
}

 

Hi  Manmohan,

Yes It is working, Thank You.