How to get user info in inbound email action script?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2010 10:51 AM
With inbound email actions all the wiki information suggests doing something such as:
current.caller_id = gs.createUser(email.from);
This is great because it assigns the incident to the user the email came from. What about additional user contact details on the incident form itself? We have phone/email contact information for the user as well but it does not appear that this is possible through the script.
Is there a better/alternative way to achieve this desired result ?
There is:
gs.getUser();
method however this returns the current user within context and this does not seem like it would apply for inbound email action. Also, getUser dose not accept an argument to return some specific user such as:
var user = gs.getUser(email.from);
Labels:
- Labels:
-
Incident Management
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2010 04:00 PM
You need to query for the user
var sid = gs.createUser(email.from);
var caller2 = new GlideRecord('sys_user')
caller2.addQuery('sys_id', sid)
caller2.query();
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2010 07:18 AM
So in regards to inbound action, although this doesn't work it has to be similar to this:
(Our , and in our .)
var caller2 = new GlideRecord("sys_user");
caller2.addQuery("sys_id",sid);
caller2.query();
//incident form has u_contact_number/u_contact_email defined as additional fields
//user profile we have phone/email defined
current.u_contact_number = caller2.phone;
current.u_contact_email = caller2.email;
To me it seems this would be straightforward, although it is not functioning correctly.
Is there a way to see a debug/console dump of what happened because that code does not appear to do anything but the inbound script as a whole still processes the email and creates an incident, does everything accordingly except setting those 2 fields.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2010 08:27 AM
Using get is actually better than using query.
This works just fine:
//lets lookup the user and set the phone/email fields of incident accordingly
var callerLookup = new GlideRecord('sys_user');
if(callerLookup.get(sid)){
current.u_contact_number = callerLookup.phone;
current.u_contact_email = callerLookup.email;
}
Thanks for the help!