- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2019 08:56 AM
Good morning!
We have support group phone numbers that send emails with audio files attached when a caller leaves a voicemail. The subject of the email contains the phone number of the caller. I would like to be able to search the business phone field on the sys_user table for a match and then set the caller of the incident to that user.
The first part of my code is working... I'm getting a number. But the second part, the query is returning nothing to the log...
anyone have any ideas?
It should be pretty easy...but I'm stuck. here is what I have so far:
var msg_phone = email.subject.slice(email.subject.indexOf('(')+1, email.body_text.indexOf(')'));
gs.log('Phone Number is '+ msg_phone);
var usr = new GlideRecord('sys_user');
usr.addQuery('phone',msg_phone);
usr.query();
if (usr.next())
{
gs.log('User id is '+ usr);
current.caller_id = usr.user_name;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2019 09:04 AM
var usr = new GlideRecord('sys_user');
usr.addQuery('phone','111-222-3333');
usr.query();
if (usr.next())
{
gs.info('User name is '+ usr.name);
}
caller_id needs the sys_id of the user record:
current.caller_id = usr.getUniqueValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2019 09:11 AM
ha that was it.... fixed it all. thank you!!