Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Can we use LENGTH in GlideRecord API

GangareddyNachu
ServiceNow Employee
ServiceNow Employee

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?

3 REPLIES 3

Anantha Gowrara
Kilo Sage

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.

debendudas
Mega Sage
Mega Sage

@GangareddyNachu ,

Try it with GlideFilter, not sure if it it will solve it or not.
Please refer this: GlideFilter and Regular Expression Match - ServiceNow Community

Brad Bowman
Kilo Patron
Kilo Patron

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.