- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 11:44 PM
Hi,
i get the Value of the Reference Field of the sys_dictionary Table
var ref_qual = gr_dic.getDisplayValue("reference_qual");
or
gr_dic.getValue("reference_qual")
With both i get
typeLIKE5f230a666fdd6100106de5ec5d3ee493^ORtypeLIKE1bff3b1493030200ea933007f67ffb6d^EQ
can someone pleas help me to get the SYSids of that String with a REGEX.
The Regey shoul also work, if there is 1 SYSid or 300 🙂
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 12:27 AM
Hi,
As in your case there will be multiple sys_ids in string, please use below regex pattern.
/[a-f0-9]{32}/g
Example :
var str="typeLIKE5f230a666fdd6100106de5ec5d3ee493^ORtypeLIKE1bff3b1493030200ea933007f67ffb6d^EQ";
gs.print(str.match(/[a-f0-9]{32}/g));
Output :
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 11:56 PM
Hi
var regexp = /[0-9a-f]{32}/;
var out = (current.u_text.match(regexp));
If you are looking for a solution to get a sys_id from a whole sentence, it is highly unlikely that the sentence will randomly have 32 hexadecimal characters in it - that's what makes the sys_id so easy to identify. That same pattern will work. It just says look for 32 consecutive characters as long as they are 0 through 9 or a-f. If it doesn't match that, I don't care.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 12:02 AM
Hi,
You can use below regex pattern to extract sys_id's from given string. If it has multiple sys_ids, it returns all separated by comma,
var str="typeLIKE5f230a666fdd6100106de5ec5d3ee493^ORtypeLIKE1bff3b1493030200ea933007f67ffb6d^EQ";
gs.print(str.match(/[a-f0-9]{33}/gi));
Output :
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 12:27 AM
Hi,
As in your case there will be multiple sys_ids in string, please use below regex pattern.
/[a-f0-9]{32}/g
Example :
var str="typeLIKE5f230a666fdd6100106de5ec5d3ee493^ORtypeLIKE1bff3b1493030200ea933007f67ffb6d^EQ";
gs.print(str.match(/[a-f0-9]{32}/g));
Output :
Let me know if you have any further queries.
Please mark this as Correct or Helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2022 12:56 AM
Thank you