Case sensitive searches in Condition fields

dariusvdb
Kilo Contributor

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.

4 REPLIES 4

Jay_Ford
Kilo Guru

You could try using toLowerCase and indexOf to get around that.



company.toLowerCase().indexOf('test') >= 0


Mike McCall
Giga Guru

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


current.company.toLowerCase();
for "Calculation."
4) In your SLA condition, search against the new field (and be sure to use all lower case values like 'test').

Thanks, Ed!


CapaJC
ServiceNow Employee
ServiceNow Employee

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.


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).