SNC User Onboarding – Part 1

General Add comments
by:

Some time ago I was implementing for a customer that did not know the list of users.

Effectively, they had the whole country as a possible customer for their support instance!
Of course this is not a standard situation, but it gives a nice example of the possibilities to control users, onboarding, company association and actualisation.

Let’s look at one of the subjects and what we came up with. Maybe you would have interesting ideas as well?

1. Onboarding:
To make sure all thinkable users will be able to register we enabled two things: automatically create users from incoming email and dynamically create users from their username on the incident form.
These two ways cover the ways to register a ticket in the instance.

Automatically create users from incoming email
– There is a standard function to do this, but it has a standard set of values it fills for a user.
Replacing it with a custom function made it more flexible and allowed us also to use the email extension to match a new user to a registered company (for correct contract and SLA handling!).
Please find a snippet of the code below. Most interesting part would be the last function, “FindCompany”. This will find the correct company, based on a custom table filled with ‘mail extensions’.
All mail from unknown people sending from ‘company.com’ will be linked to the company that has the extension connected to it.
Via this reconciliation table, a company with multiple mailaddresses can be connected to a user.
This is important, to have the correct (Service Level) Agreements in sight when processing a ticket!

function CreateUserAA(emailfrom){
var sid = "";
var vInboundEmail = emailfrom;
var vExistingUser = new GlideRecord("sys_user");
vExistingUser.addQuery("email", vInboundEmail);
vExistingUser.query();
if (vExistingUser.next()) {

sid = vExistingUser.sys_id;
}
else {
//sid = gs.createUser(email.from);
sid = NewUser(emailfrom);
}
return sid;
}

function NewUser(mname){
var gr = new GlideRecord(‘sys_user’);
gr.email = mname;
gr.user_name = mname;
var mext = mname.split(“@”);
gr.name = mext[0];
mext = mext[1];
gr.company = FindCompany(mext);
var nid = gr.insert();
return nid;
}

function FindCompany(mailext){
var comp = GetIDValue(“core_company”,”None”);
var ab = new GlideRecord(‘u_mail_extension’);
ab.addQuery(‘u_mail’, mailext);
ab.query();
if(ab.next()){
comp = ab.u_company;
}
return comp;
}

Automatically create users from the ‘Caller’ field
– For this SNC has made a standard function as well, but since we have a different onboarding structure, the ‘dynamicUserCreation’ function had to be amended.
The name of the function can only change if that is also changed in the ‘Caller’ field.
We have to check the box “Dynamic creation:” and see an extra field for the function.
For the changes to the function I would like to refer to the function above.
Similar parts are used to create the correct user record.
Important setting here was to change the display value to show the email address.
Now the only thing people have to give is their email address and their record (if not already available) will be created.

Do you have any nice contributions in this area?

Leave a Reply