Search for values containing a space character (starting with, containing, ends with)

hubertn
Kilo Contributor

I need to report on all assets with a serial number containing 1 or more spaces anywhere in the value.  

1) can wildcards be used in report and filter conditions?   e.g. * " " *

2) how would i represent the space?   escape sequence?  

3) can REGEX be used in reporting?

Thanks in advance!

1 ACCEPTED SOLUTION

Ankush Agrawal
ServiceNow Employee
ServiceNow Employee

Hi Hubert



You can create a Script Include which will have a function which returns comma separated sys_ids of the desired records. Then the same function can be used as a filter in your table.


E.g: If we want to create a report on the table sys_user where field phone contains any whitespace, we can write following Script Include:


var TestFilter = Class.create();


TestFilter.prototype = {


      initialize: function() {


      },



  getFilter: function() {


  var v = new GlideRecord('sys_user');


  v.addQuery('phone', 'CONTAINS', ' ');


  v.query();


  return v;


  },



      type: 'TestFilter'


};


And then in the report, we can use following (without quotes):


'Business Phone' 'is one of' 'javascript:new TestFilter().getFilter()'



Please refer to Reference Qualifiers - ServiceNow Wiki   for further details.


View solution in original post

7 REPLIES 7

Worked for me as well. thanks

wonderfully simple.  thank you

Matt Heger
Tera Expert

Hi Adam, 

what is the likely hood you replying to a 9 year old thread with a solution I need then 4 days later! Craziness but thanks a lot! 
cheers,

matt