Creating a caller from an inbound email action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 01:09 PM
Hi I am using an inbound email action to parse an email into a 'Customer Interaction' on the 'sn_customerservice_customer_interaction' table. We created a "Callers" table which extends the customer contact table and within my inbound action I have code to create a new caller from the email address within 'email.from.'
It's setting the email on the email field in the interaction form and everything else works with the inbound action but the thing I've been trying to fix is it creating a new caller and inserting that information into the reference fields on the interaction form.
It does create a new user in the sys_user table but I need that record in the Callers table
Any and all help is very much appreciated!
Code:
//Query callers table if caller exists
var newCaller = new GlideRecord('u_callers');
newCaller.addQuery('email', current.email);
newCaller.query();
//If no caller exists with that email address, create a new caller
if (!newCaller.next()) {
current.u_first_time_calling = true;
newCaller.newRecord();
newCaller.user_name = current.email;
newCaller.email = current.email;
newCaller.first_name = current.first_name;
newCaller.last_name = current.last_name;
newCaller.phone = current.phone;
newCaller.insert();
}
current.u_caller = newCaller.getUniqueValue();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 01:20 PM
Bit confused. Is it or is it not creating user or what is expected kindly you kindly help clearing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 02:37 PM
It is not creating a user, to clarify:
I have a custom table called 'u_callers' which is supposed to be a table of callers (i.e. anyone who will email into the instance). I need to take that email address and create a caller in that table does that make more sense?
They won't actually be users of the system but this is just to keep track of if they have emailed in before or if they are first time callers (first time emailing in).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 02:38 PM
And when I say it is not creating a user I mean it is not creating a caller in the caller's table as it should.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 08:01 PM
I also tried this way of creating and getting the user record, and from there inserting the record into the callers table and nothing.
var user = new GlideRecord('sys_user');
user.addQuery('email', email.from.toString());
user.query();
if (!user.next()) {
user.initialize();
user.email = email.from;
user.insert();
var newCaller = new GlideRecord('u_callers');
newCaller.addQuery('email', email);
if (!newCaller.next()) {
newCaller.initialize();
newCaller.email = user.email;
newCaller.insert();
}
}