- 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 08:34 AM - edited 11-03-2022 08:42 AM
Hi ,
put some log to check what values are you getting .
gs.log('Email Subject" +grstring);
check after that
like gs.log( "Caller id : " + callerID); gs.log( " Current Caller id : " + current.caller_id);
Also check if your code is working inside the loop . Try to replace the line gr.addQuery('name', callerID);
Try buddy it will work . Follow the steps . Go to Logs and Validate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 09:38 AM
Hi @MD AQUIB KHAN ,
I tried after updating 8th line with "user_name" and adding logs. caller is undefined showing in the logs.
System logs:
2.
- 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 08:18 AM
Hi @raycallan,
I am getting the short description and description but still, the caller is empty.
Inbound action: I also tried adding "User updated User Id: " in the 2nd line of the script.
- 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]);