
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2019 04:51 PM
G'day all,
I've a requirement such that as soon as an email will be received an Inbound Email Action Script should run, which will fetch the incident number from the body of that email and put it into a custom field created on Incident table.
The email received is like this:
The incident number highlighted in Yellow should be trimmed from the email body and should be placed in a custom field - u_new_incident field on Incident Table.
Can some do me a massive favor by providing script that can be used to achieve this requirement.
Cheers-
Rahul J.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2019 08:55 PM
Finally, I found a solution to this requirement.
I created an Inbound Email Action like this:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Implement email action here
var rSubject=email.subject;
var bod=email.body_text;
var bod1=bod.toString();
var rBody=bod1.substring(0,12);
var inc1= new GlideRecord('incident');
inc1.addQuery('number',rSubject);
inc1.query();
gs.print("rows"+ inc1.getRowCount());
if (inc1.next()){
inc1.u_new_incident=rBody;
inc1.update();
}
})(current, event, email, logger, classifier);
And, everything worked smoothly. A big shoutout to community members who helped me in achieving this.
Cheers-
Rahul J.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2019 10:45 PM
Hello rahul,
can you send me a sample email body format? So I can help you to trim data. I have implemented a same functionality in my project.
Thanks,
Abhishek
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2019 06:13 PM
Hi Abhishek,
Sorry for the late reply
My subject line just include an Incident number: INC0021977
and my requirement is put this incident number onto a custom created field on Incident table.
The custom created field : u_new_incident
For this purpose I have created an Inbound Email Actions as:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Implement email action here
current.u_new_incident = email.subject;
})(current, event, email, logger, classifier);
as suggested by @Manish in this thread.
Would really appreciated ya help.
Thanks,
Rahul J.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2019 06:31 PM
G'day Abhishek,
Sorry for the late response.
So, email body is like this:
<html><head></head><body><p> This incident number is coming from target instance: RXINC0017129</p><div> </div><div style="display:inline">Ref:MSG0021431_weKJ2DjFaVkJwE5SiVgs</div></body></html>
From the aforementioned body of email I want to trim the portion highlighted in yellow onto a custom field called: u_new_incident (this field is present in Incident table).
Cheers-
Rahul J.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2019 11:31 PM
Hi Rahul,
Please refer below link:
Pull information from email body for inbound action
It will help you.
Kindly mark correct or helpful if it helps you to solve your query.
Thank You,
Ashvini k

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2019 08:55 PM
Finally, I found a solution to this requirement.
I created an Inbound Email Action like this:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Implement email action here
var rSubject=email.subject;
var bod=email.body_text;
var bod1=bod.toString();
var rBody=bod1.substring(0,12);
var inc1= new GlideRecord('incident');
inc1.addQuery('number',rSubject);
inc1.query();
gs.print("rows"+ inc1.getRowCount());
if (inc1.next()){
inc1.u_new_incident=rBody;
inc1.update();
}
})(current, event, email, logger, classifier);
And, everything worked smoothly. A big shoutout to community members who helped me in achieving this.
Cheers-
Rahul J.