Is addQuery case sensitive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2016 05:04 AM
Hi, I want to know is addQuery case sensitive? My case is that I have a business rule, which calls a script include in which I am using the addQuery option. The script include aims to check for duplicate records in a table. However, what I want is for this to be case sensitive as right now if I have a record Test and then try to enter another record TEST I am unable to do so.
My code for the script include is:
var CIMatcher = Class.create();
CIMatcher.prototype = {
initialize: function(current) {
this.record = current;
},
getCIIdentifier:function (){
var gr = new GlideRecord('u_ci_class_lookup');
gr.addQuery('u_ci_class',this.record.sys_class_name);
gr.query();
if(gr.next()){
var i = 0;
var ciclass = ''+ gr.u_ci_class;
//split all our field names into something we can query
var fields = gr.u_fields.split(',');
var ci = new GlideRecord(ciclass);
ci.addQuery('sys_id','!=',this.record.sys_id.toString());
//loop through all fields in lookup table with values from 'current'
while(i < fields.length){
var field_value = eval("this.record." + fields[i].toString());
if(JSUtil.nil(field_value.trim())){
return false;
}
ci.addQuery(fields[i].toString(),field_value);
i++;
}
ci.query();
if(ci.next()){
new CIException().add(this.record,'Duplicate');
return false; //abort insert log exeception
}
return true;//nothing found proceed as normal
}
//no class identifier for this table
return true;
},
type: 'Matcher'
};
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 05:40 PM
No worries.
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 02:46 AM
Hi guys,
I'm also confused.
Chuck when you say "("normal" is different than "Normal").". What do you mean?
I've tried what support said, and they seem to be correct:
I've 3 CI's with name: "Telmo FTP", "TELMO ftp" and "Telmo ftp".
And if I run:
var ftpGr = new GlideRecord('cmdb_ci_endpoint_ftp');
ftpGr.addQuery('name','Telmo FTP');
ftpGr.query();
gs.print(ftpGr.getRowCount());
while (ftpGr.next()){
gs.log(ftpGr.name);
}
I got 3 and not 1 result:
*** Script: 3
*** Script: Telmo FTP
*** Script: TELMO ftp
*** Script: Telmo ftp
Regards,
Telmo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2016 05:35 AM
You are correct Telmo. It seems underneath, addQuery() is doing a case insensitive search. This aligns with the list filter/condition builder. I was thinking about in scripting, when looking for choice list values, checking "New" and "new" is not the same.
if (current.state == 'New') { // fails if state VALUE is 'new' and the label is 'New'
}
Thank you for sharing!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2020 04:17 AM
Hi Chuck,
I have a similar requirement. Suppose I am gliding asset table.
I have different assets with the asset tags say "ABC", "ABc", "Abc" and "abc" respectively.
Now, how can I identify them in the glide record using addQuery.
Because addQuery('asset_tag','myAssetTag') return all four assets.
Please help on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-09-2016 06:15 AM
Based on your script it looks like you might be trying to create a CI Identification mechanism?
If so, why not use the OOTB one: CMDB Identification and Reconciliation