- 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 06:36 AM - edited 11-03-2022 06:41 AM
var gr = "User Updated : abel.tuter";
var arr = [];
arr = gr.split(':');
gs.print("Array 1:" + arr[0]);
gs.print("Array 2:" + arr[1] );
try to replicate the same with email.subject;
get the email.subject in the variable.
var grstring = email.subject;
var arr = [];
arr =grstring.split(':');
var callerid = arr[1];
then current.caller_id = callerid;
I tried in the background script scripts. It will come like this.
if the above solution will not work. than try this also
var gr = new GlideRecord('sys_user');
gr.addQuery('name', callerid.toString()); // Please pick the correct backened value of the username /name . callerid is from the email subject after the split
gr.query();
while (gr.next()) {
current.caller_id = gr.sys_id
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 06:08 AM - edited 11-03-2022 06:09 AM
Hi @Hari S1 ,
A few questions
- Is this for all inbound email or only for certain email addresses
- What is the format of the caller (eg full name, user name, email)
- Does the subject only contain the caller or doe we need to split the subject to get the caller
Do you have an example of the your subject line looks like
You would probably need to script something like this if searching by full name
var gr = new GlideRecord('sys_user');
gr.addQuery('name', email.subject);
gr.query();
while (gr.next()) {
current.caller_id = gr.sys_id
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 06:49 AM
Hi Raycallan,
Thanks for the response.
1. It is only for one email addresses(Example: xyz@gmail.com), not for all inbound emails.
2. Format of the caller is user name.
3. Yes, the subject contains the caller but the caller id might change(dynamic).
Yes, I have the subject line: Example: User updated User Id: abel.tuter(User Id might changes)
I tried the below script but still, the caller is empty.
Thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 07:02 AM
try this once
var grstring = email.subject;
var arr = [];
arr =grstring.split(':');
var callerid = arr[1];
gs.log ('Caller:' +callerid );
var gr = new GlideRecord('sys_user');
gr.addQuery('name', callerid.toString()); // Please pick the correct backened value of the username /name . callerid is from the email subject after the split
gr.query();
while (gr.next()) {
current.caller_id = gr.sys_id;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 08:24 AM