- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 09:24 PM
hello everyone
I have a question about how toString() is used
var s = sys_email.sys_id;
var mm = s.subject.toString();
var reg = /\[[0-9]+\]/;
var result = (mm.match(reg) + "").match(/[0-9]+/)+ "";
Why can't this script extract the number from the email subject line?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:38 PM - edited 12-19-2022 10:40 PM
@sirou You dont need to do GlideRecord on email table.
email object itself is gliderecord object.
var s = email.subject.toString();
The above line should give you subject. dont query email table
Replace line 3,4,5,6,7 with above line
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 09:49 PM
@sirou Some times the string field returns the object, to make sure we get the string output we add toString().
Please mark as helpful based on impact.
If any other question regarding code please add full code with more info.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:35 PM
I'm trying to put the "subject" in the description in inbound Email Actions.
The picture is the script I wrote.
However, this results in a value of "null"
Am I doing this wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:38 PM - edited 12-19-2022 10:40 PM
@sirou You dont need to do GlideRecord on email table.
email object itself is gliderecord object.
var s = email.subject.toString();
The above line should give you subject. dont query email table
Replace line 3,4,5,6,7 with above line
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 10:49 PM