Can we use LENGTH in GlideRecord API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 10:24 AM
Hi,
I have territory_path = "TER13/TER14/TER15"
I want to get the records with territory_path until level 2 something like TER13/TER14
Can GlideRecord Api supports using LENGTH something like gr.addEncodedQuery("LENGTH(territory_path)=2"); Can someone please help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 10:33 AM
Hi @GangareddyNachu , if your field is of string type then you can do something like this.
Var str = "TER13/TER14/TER15"
var splitVal = str.split("/");
then you can use splitVal[0] that should give you TER13 and splitVal[1] gives you TER14. Afteer getting these 2 values you can concat both values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 10:35 AM
Try it with GlideFilter, not sure if it it will solve it or not.
Please refer this: GlideFilter and Regular Expression Match - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 10:47 AM
I wouldn't see that as a possibility in an addQuery/addEncodedQuery method, but for each record returned, you can test the length of the value of a field, then push that sys_id to an array or whatever to limit the table to these records.