- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2019 09:45 PM
I have the below background script, which will display matching Short description. I'm not getting the output properly
var arr = [];
var regex = /SAP/i;
var strSD='';
var stdDesc='';
var gr = new GlideRecord('incident');
gr.query();
while (gr.next())
{
strSD= gr.short_description;
if(regex.test(strSD))
{
arr.push(strSD);
gs.info(arr);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2019 09:49 PM
Hi,
following is the updated script; use toString()
you should print the array outside the while loop to get the final array
var arr = [];
var regex = /SAP/i;
var strSD='';
var stdDesc='';
var gr = new GlideRecord('incident');
gr.query();
while (gr.next())
{
strSD= gr.short_description;
if(regex.test(strSD))
{
arr.push(strSD.toString());
}
}
gs.info(arr);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2019 09:49 PM
Hi,
following is the updated script; use toString()
you should print the array outside the while loop to get the final array
var arr = [];
var regex = /SAP/i;
var strSD='';
var stdDesc='';
var gr = new GlideRecord('incident');
gr.query();
while (gr.next())
{
strSD= gr.short_description;
if(regex.test(strSD))
{
arr.push(strSD.toString());
}
}
gs.info(arr);
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader