Case sensitive searches in Condition fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2010 12:27 AM
We have seen that some searches on our SLA engine condition items are case sensitive, is there a way to switch this off?
For example the Start conditions for a SLA item is met if for example it is Company = Test, but if we have Company = test it is not met.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2010 05:43 AM
You could try using toLowerCase and indexOf to get around that.
company.toLowerCase().indexOf('test') >= 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2013 06:24 PM
I ran into this issue today, and Ed Wajs at ServiceNow suggested creating a calculated field exclusively for searching. (He also pointed me to the wiki article that documents the situation: http://wiki.servicenow.com/index.php?title=Defining_an_SLA#Defining_an_SLA)
In the example above, this workaround would mean:
1) On your target table, add a custom 'u_company_lc' field.
2) On the new field, check "Calculated" and "Read only."
3) On the new field, fill in
for "Calculation."
current.company.toLowerCase();
4) In your SLA condition, search against the new field (and be sure to use all lower case values like 'test').
Thanks, Ed!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2013 07:16 AM
Wait, is Company a reference field, or just a plain String? If it's a String, disregard the rest of this 🙂
If it's a reference field, and you set it to Company = Test, you're saying that Company has to be the exact record you selected when you set up the condition. It's a unique sys_id value you're matching on, not the display name of the Company. So if you have two companies, one "Test" and one "test", the only one that can match is the one you selected initially when setting up the reference condition.
If you wanted to match either, you'd need to do Company.Name = test. Then it would match either, since Name is a String field and String field comparisons are case insensitive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2013 08:23 AM
My workaround below was actually for the short_description field, so it's definitely only useful for strings.
I'm curious about whether "Company.Name = test" would always work, though. My new understanding is that string comparisons in SLA conditions are case-sensitive, so I would expect this to only match companies named "test" (in all lower case).