Get the user email

asher14
Tera Contributor

Hi, I'm working in the script include to get the users email. Currently it is not getting the users email and would like some help.

 

Here's the script below:

               var leadUser = vtmrGR.u_user_ref;
                var leadGR = new GlideRecord('sys_user');
                if(leadGR.get(leadUser)){
                    var leadEmail = leadGR.email;
                    email.addAddress("cc", leadEmail);
                }
5 REPLIES 5

maroon_byte
Mega Sage

Try:

 

var leadUser = vtmrGR.u_user_ref.toString();
                var leadGR = new GlideRecord('sys_user');
                if(leadGR.get(leadUser)){
                    var leadEmail = leadGR.email;
                    email.addAddress("cc", leadEmail);
                }

That didn't seem to do it when I tested

Can you please provide more details around why you need to get user's email?

Anubhav24
Mega Sage
Mega Sage

Hi @asher14 ,

Is the if condition returning true value ?

Also you can try to hardcode a sys_id in "leadUser" variable and then try the same script in background script to see if it returns the result properly else it will throw some error which you can fix.

Please mark helpful/correct if my response helped you.