- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2017 09:14 AM
Hi,
I need to write a script to extract a number from the subject of the mail.user sends a mail to dev****.servicenow.com.
From System Policy > Email > Inbound Actions I have configured:
and in actions tab I have mentioned the actions when a mail is received:
Now I need to write a script that may take a number from the mail subject and insert it in a custom field.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 03:40 AM
The code you added in the previous screenshot is wrong.
Can you please replace it with this
var rsubject=email.subject;
var keyword="Ticket#: ";
var len = keyword.length;
var key = rsubject.indexOf(keyword); //Assuming this text would never change
if(key > 0){
var number = rsubject.substring(key+len, 7);
gs.log(number, "TEST"); //Try logging number
current.u_ast_id = number;
current.update();
}
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 03:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 03:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 03:40 AM
The code you added in the previous screenshot is wrong.
Can you please replace it with this
var rsubject=email.subject;
var keyword="Ticket#: ";
var len = keyword.length;
var key = rsubject.indexOf(keyword); //Assuming this text would never change
if(key > 0){
var number = rsubject.substring(key+len, 7);
gs.log(number, "TEST"); //Try logging number
current.u_ast_id = number;
current.update();
}
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 03:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2017 04:00 AM
Great! Happy to help
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response