- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2020 07:28 PM
Trying:
var regexp = /Status:(.*)/g;
if (str.match(regexp)) {
str = str.match(regexp);
gs.log('*** ISSUE: strRegEx = ' + str);
var status = str.split(" ");
gs.log('*** ISSUE: Status = ' + status[1]);
Getting:
Information *** ISSUE: strRegEx = Status: Done (was: Testing)
Warning org.mozilla.javascript.EcmaError: Cannot read property "1" from undefined
Caused by error in sysevent_script_action.95636cdbdba1181072bea04913961902.script at line 10
7: str = str.match(regexp);
8: gs.log('*** ISSUE: strRegEx = ' + str);
9: var status = str.split(" ");
==> 10: gs.log('*** ISSUE: Status = ' + status[1]);
Information *** ISSUE: Status = undefined
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 05:10 AM
It looks like it's not able to split str, so forcing str to a string should do it
str = str.match(regexp).toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2020 08:05 PM
Hi,
var regexp = /Status:(.*)/g;
str = str.match(regexp);
gs.log('*** ISSUE: strRegEx = ' + str);
var status = str.split(" ");
gs.log('*** ISSUE: Status = ' + status); //try like this check what happend
Thanks,
Kunal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 12:57 AM
Hi Jason,
If I understand correctly this is not the complete code. Can you share the complete code once.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 05:10 AM
It looks like it's not able to split str, so forcing str to a string should do it
str = str.match(regexp).toString();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2020 06:58 PM
Yes! Thank you!! After I thought about it make sense why it was saying it was undefined and it needed to be defined as string.
Thank you Brad! Thank you ServiceNow community so helpful!!