How to fetch email from user sys_id

Hareesha
Tera Contributor

I have a updated by field on intake form which is of type string,which is holding userid's. I have to fetch the email of that user'id. How can i do that? Does anyone have idea? Tried below script but not working.

 

var usr = new GlideRecord('sys_user');
    usr.addEncodedquery('user_name=', +current.sys_updated_by);
    usr.query();
    if (usr.next()) {
        gs.eventQueue('get_submitter_email', current, usr.name);
    }

3 REPLIES 3

Ramkumar Thanga
Mega Sage

Hi Hareesha,

 

Follow the below syntax.

 

gs.eventQueue('event.name', GlideRecord, parm1, parm2); 

 

you can pass the email into parm1 or parm2 and don't forget to mention in the notification.

 

gs.eventQueue('get_submitter_email', current, usr.name, usr.email); // I am passing the email id the parm2.

 

Please mark this as helpful/Correct

Ramkumar Thanga
Mega Sage

Hi Hareesha, 

 

May I know from where you are triggering the event, for eg. Business Rule/Schedule job. Based on this I can simplify your code.

 

Thanks!!

Ramkumar.

Hi RamKumar,

I wrote above code in business rule and calling the event