Querying on length of data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2015 09:51 AM
I would like a query to find those rows in a database table where the length of the data in the field meets a certain condition. For example, I want all users where the length of the phone number is greater than 15 - this could indicate a data entry problem, for example.
How can this be done using a GlideRecord?
(I have a similar question regarding doing such queries on a List view in the UI.)
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2021 04:57 AM
That's the way! thanks! btw how did you find that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 12:27 AM
There was a requirement that the Short Description field be shortened from 255 character length. Field cannot be changed in the table, because the data already contains long characters.
I create in the script below which report is exceeded records in ServiceNow all table which extend from task table.
var gr = new GlideRecord('task');
gr.addQuery('glidefunction:length(short_description)>250');
gr.query();
gs.info(gr.getRowCount());
while(gr.next()){
gs.info(gr.number);
}
