Find sys_id vaues in scripts

Salvador Marcha
Kilo Guru

Hi,

I have this regex (below) that works to match a sys_id value.

 

/["']([a-z0-9]{32})["']/g

 

How do I search different various scripts (Script Includes, Business Rules, UI Action, client Script, etc) using this regex? (I can't figure out the syntax using 'new RegExp()' ...or, is there another way?)

 

Thanks in advance,

SM

 

3 REPLIES 3

Manmaya Kumar S
Tera Expert

Okay , if you are looking for a sys_id value that is hardcoded in any script, then in stead of a regex, you can basically do a global search against all the tables across application in servicenow studio.
- Just open the studio and switch to any application that allows to edit it, for example any workspace related applications.
- And then use the code search feature over there and make sure to check the checkbox on search on all applications.

Let me know if this helps.
Thanks!


ManmayaKumarS_0-1738684864635.png

 

ManmayaKumarS_1-1738684890348.png

ManmayaKumarS_2-1738684933911.png

 

Salvador Marcha
Kilo Guru

Hi,

I'm looking for ALL hardcoded sys_id values (32 alphanumeric characters) and not a specific sys_id or the code "sys_id" in the script.

My plan is to convert those sys_id values and store them in sys_properties table.

Manmaya Kumar S
Tera Expert

Okay then in that case, i don't think there's an easier way to do it, you will have to run your reg exp against the scripts present in different records such as BRs, Script includes, client scripts etc.

That's why its important not to hardcode any sys_id rather storing them in a system property is a better way to go about it since its a lot easier to handle and manage.

Please mark this as helpful if you can.

Thanks!