- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 05:46 AM
Hi,
We are trying to get the caller id from the email subject of the inbound action email and set it as a caller for the incident.
Thanks for any help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 07:32 AM
Hi @Hari S1
This should work for you
if (email.origemail == '[email_address]') {
var arrSubject = email.subject.split(' : '); //need to include the
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', arrSubject[1]);
gr.query();
if (gr.next()) {
current.caller_id = gr.sys_id
}
} else {
current.caller_id = gs.getUserID();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 09:00 AM
You need to replace [email_address] with the email address that the email is coming from
Its also a good idea during testing to log what is happening to make it easier to troubleshoot
For example insert the following at line 3
gs.log ('Caller: ' + arrSubject[1]);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 05:51 AM
Hi,
Please elaborate your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 05:53 AM
You get the caller from email.from objevt , from that email you can get the sys_id of user by gliding the user table.
If you are getting something specific in the email, then it should be at a defined place , like the subject should start with caller id. In that case you can perform string operations on the email.subject and get the caller id.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 05:55 AM
Hi,
I guess this is what you are looking for
current.caller_id = email.subject;
Please share any scripts if you have
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 06:23 AM
Hi Aquib,
Thanks for the quick replay.
I sent an email to ServiceNow to create an incident in Servicenow and I mentioned the user Id in the email Subject but still no caller in the incident form.
Inbound action:
Thanks.