- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:07 AM
So I have a requirement to filter SN on the 5th and 6th positions of a server name. This is in Helsinki and on a reference field within a Record Producer. I can't seem to get either matches pattern or matches regex to work. I get a lot of SQL/MySql errors. What's the trick? I'll keep googling. Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2018 11:53 AM
The biggest WTF is that a feature - known broken and recommended not to be used - still hasn't been pulled.
If it doesn't work and serves no purpose... why leave it in?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:21 AM
Hello Steve,
Take the Display Value of Reference Field (Server Name) like this -
g_form.getDisplayBox('field_name ').value;
After that perform your matches regex-
https://www.w3schools.com/jsref/jsref_match.asp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 06:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 10:49 AM
I agree Steve...I can't get this to work.
Can we get an expert to chime in on how to use these pattern match options?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 11:22 AM
I have no idea how to get the items to work that I tried to work. So I went with a script includes in the reference qualifier field of a list collector instead. HOWEVER, it returns every record not my filtered records. Here is my code. It's been tweaked from code I found elsewhere. Not sure why I get every record returned though.
var KHNCheckTrackboardComputers = Class.create();
KHNCheckTrackboardComputers.prototype = {
checkcomputers: function() {
var str = "";
var regexp = /^.{4}(sn|SN|Sn|sN)/g;
var gp = "";
var firsttime = true;
//Get a query of computers with SN in their name.
var grp = new GlideRecord('cmdb_ci_computer');
grp.addQuery('name', 'CONTAINS', 'SN');
grp.query();
gs.log('smsb debug rowcount -> ' + grp.getRowCount());
while(grp.next()) {
str = grp.name;
//gs.log('smsb debug value of str -> ' + str);
if (regexp.test(str))
{
gs.log('smsb debug found a regex match');
if (firsttime)
{
gp += grp.name;
firsttime = false;
}
else
{
//build a comma separated string of groups if there is more than one
gp += (',' + grp.name);
}
}
}
gs.log('smsb debug value of gp -> ' + gp);
return 'sys_id_IN' + gp;
},
type: 'KHNCheckTrackboardComputers'
};