User name is in a string field. How to get email of that user?

shweta14
Tera Contributor

I want to send notification to user but user is in a string field how to get email of that user

1 ACCEPTED SOLUTION

Ok, Got it..

Follow the steps below... It works...tested..

Step 1: Create a event registry record like below.

1.) In navigator, type this "sysevent_register.LIST" and click on new and fill the below details.

find_real_file.png

 

Step 2 : Create after insert/update business rule

find_real_file.png

 

In advance write the below script

(function executeRule(current, previous /*null when async*/ ) {
    getUsername = current.write_serviceowner_fieldname;
    var gr = new GlideRecord('sys_user');
    gr.addQuery('user_name', getUsername);
    gr.query();
    if (gr.next()) {
        gs.eventQueue('notify.event', gr, gr.email);
    }
})(current, previous);

 

Step 3: Create notification like below.

find_real_file.png

find_real_file.png

I hope it helps, if so please mark my response as helpful and correct.

 

View solution in original post

12 REPLIES 12

Musab Rasheed
Tera Sage
Tera Sage

Hi Shweta,

Is user part of User table.? why not use reference field instead of string field.? what's the business purpose.?

Please hit like and mark my response as correct if that helps
Regards,
Musab

shweta14
Tera Contributor

I want the configuration item service owner but every time item changes how to get that service owner email to send notification 

 

To pull email address of user from string field is difficult because there might be multiple entries in user table of same name hence asking you don't you use reference field.? what type of field is service owner? String or reference.? post screenshot here.

Please hit like and mark my response as correct if that helps
Regards,
Musab

It is string field please find above screenshot