The CreatorCon Call for Content is officially open! Get started here.

email.addAddress of current user

asher14
Tera Contributor

I am writing a script include.

I am trying to add the Address of the user who created the request.  How do I add the sys_created_by or sys_id email of the person who created the request?

 

if(current.getValue('u_drop_off') == '1' {

    var dropOff = gs.getProperty('Location');

    email.addAddress(dropOff);

    email.addAddress(EMAIL OF THE USER WHO CREATED REQUEST);

}

1 ACCEPTED SOLUTION

If you want to send email to the requester, in the User/Group in fields, you can select the field which holds the user value.

SanjivMeher_0-1671744795848.png

If you want to send email with user in CC, you can use script 

if(current.getValue('u_drop_off') == '1' {

    var dropOff = gs.getProperty('Location');

    email.addAddress('cc',dropOff);

    email.addAddress('cc',current.requested_for.email);

}

 

Can you also confirm, your notification is on sc_request table?


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

18 REPLIES 18

asher14
Tera Contributor

When I hard code email.addAddress('cc', ashle@test.com, 'Ashle'); It is returning in the copied field. But not dynamically based on whoever triggers the request

 

You can try out using toString() at end or do hit and trial by checking and unchecking the 'send to event creator field'. Not sure but might work.

 

Did you get any chance to check the actual email triggered? in that it showing in cc or not.

 

You should see the last few replies of the below post. It might help.

https://www.servicenow.com/community/now-platform-forum/email-notification-to-cc-current-logged-in-u...

 

Regards,

Kartik

 

James160
Mega Guru

btw,  email.addAddress is a scoped api. what shall we do if we work under Global scope?

Hi,
It will work in global scope as well.

 

 

 


Thanks and Regards,

Saurabh Gupta