Create incidents from external users by mail

Hichem
Mega Expert

Hello,

I'm trying to allow external users to create incidents through emails (whitout having accounts).

I've found in this forum below code snippet.
The inbound email action successfully create an incident, but nothing in user and caller fields.
What I want is to populate these fields with Guest user if email sender is not found in the sys_user table and add in a specific field "u_guest_email" sender email.

Any help would be greatly appreciated

Thanks

-----------------------------------
current.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
current.short_description = email.subject;

var eto = email.to.toLowerCase().toString();
// var sid = gs.createUser(email.from);
var sid;
var rec = new GlideRecord('sys_user');
rec.addQuery('email',email.from);
rec.query();
rec.next();

if(rec.sys_id != "") {
sid = rec.sys_id;
} else {
gs.getUser();
sid = gs.getUserById('guest').sys_id;
}

current.caller_id = sid;
current.opened_by = sid;
//current.watch_list = email.from;
current.state = 1;
//current.notify = 2;
current.contact_type = "email";

//if(eto.indexOf("accounts") > -1){
//current.assignment_group.setDisplayValue('Account Support');
//}
//else{
//current.assignment_group.setDisplayValue('Consulting');
//}

current.insert();
-----------------------------------

17 REPLIES 17

It's strange but I don't have any "Guest" user.


That user account must have been removed. What will happen without a guest account if an email isn't associated to a specific user, the inbound action won't produce or update any records. It needs the guest user account in order to process unknown email addresses.


Ok, guest account created and you're right, now incidents are opened with guest account if mail not found in sys_user table !

How can I now send notifications to the person who opened the incident ?

When an external user open an incident by mail, I have a new incident with caller and user set to "Guest", but when for example I send a "Request info" or add comment on the ticket, how can he be notified ?

Thanks a lot for your help Aaron !


I'm glad that part got sorted out 🙂

Are you asking how to notify the original person of a Guest user when a typical email notification gets sent out for that record (ie: a ticket gets updated or resolved)?

Out of box there's no way to do that for a guest user. What should happen is the service desk person taking the ticket should find a real account for that individual upon first contact and update the record so it shows the user's account instead of the guest account. Then all notifications and everything else will flow the way they should.


Thank you Aaron for you help.

I've found a litte workaround which consist in adding a new field in the incident form "u_guest_mail"
in the inbound action, I've added => current.u_guest_mail = email.origemail;
with this, a new incident is opened with Guest account but also with the customer email in my field "Guest Mail"

Now just added for the notifications (opened, resolved, closed) in the "who will receive" tab, the "Guest Mail" field if not empty !


Thanks again mister Aaron 🙂