Server-side GlideRecord addQuery case sensitive

xiaix
Tera Guru

Looking at this Case insensitive Glide Record query   I see they talk about client side GlideRecord queries.

I need server side to be case sensitive.

find_real_file.png

The highlighted sections must be a cAsE sEnSiTiVe check.

How can I make it so?

10 REPLIES 10

Nate23
Mega Guru

GlideRecord queries are case insensitive. I think your best option is to pull what you have there and do a quick String comparison such as:


idk if you need the .toString() but i put it there just in case...



....


while(gr.next()){


        if(gr.u_quick_access_event_title.toString() == input.addQuickAccessEvent.toString()){


        //execute code here


        }


}


Yeah, since I can't do it in the addQuery, I'll have to do it afterward by manually pulling the value and then using javascript to compare ASCII values.


DUGGI
Giga Guru

I would suggest validate before adding into query the "input.addQuickAccessEvent" if its case sensitive do glide query.




Procedure for Ensuring Your Custom Scripts Work with Case-Insensitive Text


If your Inbound Email action scripts contain Javascript patterns similar to the following, then it is best practice to review your code for possible case-sensitivity issues. An example of case-sensitive Javascript looks like this:


Bad practice, because indexOf() requires perfect case-sensitive comparison:


if (yourVariable.indexOf("Incident Opened") != -1) {
      // Do something important here, based on text "Incident Opened"
      // The problem is that "Incident Opened" will not match
}

Best practice:


if (yourVariable.toLowerCase().indexOf("incident opened") != -1) {
      // This will match "Incident Opened", "incident Opened", "Incident opened", etc.
}

xiaix
Tera Guru

I wrote this:



find_real_file.png




Which works great:



find_real_file.png