How to create a GlideRecord Query for NOT STARTSWITH

Rajanmehta
Mega Guru

Hello

We are on Jakarta. I have a need to filter out IP address which starts with 172.

How can I add to my query? Any help on syntax would greatly appreciated.

rec.addQuery('ip_address', 'STARTSWITH','172.');   ( I want to add query like this but with negation i.e. Does not Starts with)

Thanks,

Rajan Mehta

1 ACCEPTED SOLUTION

Hi dan.bruhn,



Please help to convert this post from discussion to question. Thank you for your help.


View solution in original post

15 REPLIES 15

Anantha Gowrara
Kilo Sage

Hi Rajan,

 

I had requirement to restrict specific groups(prefixes was given which we need to eleiminate) to restrict for specific users and i wrote below code 

(function executeRule(current, previous /*null when async*/) {

              var group_prefix = gs.getProperty('GroupPrefixes'); // replace with your system property

              var group_splitted = group_prefix.split(',');

              var query = 'nameSTARTSWITH'+group_splitted[0];

              for(var i=1;i<group_splitted.length;i++){

                             query = query+"^ORnameSTARTSWITH"+group_splitted[i];

              }

              var final_groups =[];

              var allGroups = new GlideRecord('sys_user_group');

              allGroups.addEncodedQuery(query);

              allGroups.query();

              while(allGroups.next()){//final_groups.push(allGroups.sys_id);

                             current.addQuery('sys_id','!=',allGroups.sys_id); // this will eliminate those groups

              }

 

 

Regards

Anantha Gowraram