glide query size of a string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2012 05:34 AM
Hi,
in a business rule, I have to query a table to return all the records with a name with a size of 4 characters.
Is there a way to do that in a glide query?
something like that :
var dep = new GlideRecord("cmn_department");
dep.addQuery("nameLIKE"+current.u_dep_temp);
dep.addQuery("name.length==4");
dep.query();
if(dep.getRowCount() == 1)
....
Thank you so much!
Regards
Xavier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2012 05:49 AM
var arr = [];
var ci = new GlideRecord('cmdb_ci');
ci.query();
while(ci.next()){
if(ci.name.toString().length == 4){
arr.push(ci.name.toString());
}
}
//do something with your array
gs.log(arr.toString());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2012 06:23 AM
but I have to query all the table for that, what I'm looking for is a way to query on that size.
but thanks anyway!
The temporary solution I've found is to create a field u_name_size on the table cmn_department. I've a Br before insert or update that update that field.