Solved: Client template - from field set to "javascript:gs... - ServiceNow Community

Client template - from field set to "javascript:gs.getUser().email"

MKelly83
Giga Expert

Hi All

I have an client template where the from field to set to javascript:gs.getUser().email, The audit trial is being updated and the email is appearing in the outbox as sent however the email is not triggering.

I have selected Yes in the check box for Override the email 'From:' address in the email client. (System Properties > UI Properties).

Do I need to create a mail script and include in client template body?

1 ACCEPTED SOLUTION

Hi Michelle,



Sorry, i mis-read your question, i thought you were adding recipients. You should be able to set the from address using the below syntax in the from field.



javascript:gs.getUserDisplayName()+" <"+ gs.getUser().getEmail()+">"



Set the from address with an email client template


View solution in original post

8 REPLIES 8

Dubz
Mega Sage

Hi Michelle,



You can't dot-walk to user fields using the glide system so gs.getUser().email won't return anything, it doesn't open a glide record it just gives easy access to a few of the logged in users details.



However, you should be able to just put gs.getUser() and the system will send to that users email address automatically.


Thanks for your reply David



without dot-walking (.email ) it returns a value similar to this "From:com.glide.sys.User@188b4d0" also the same thing is happening logs in the audit trial and is appearing in the outbox as sent but the actual email is never sent.



Audit trial


find_real_file.png


outbox



find_real_file.png


Hi Michelle,



You have to do some scripting here.



You will have to override it my using mail script.



Use email.setFrom(current.caller_id.email);



Thanks


Thanks Ashutosh



I created the below mail script



(function runMailScript(current, template, email, email_action, event) {



                      email.setFrom(gs.getUser().getEmail());



}) (current, template, email, email_action, event);




Then called it using ${mail_script:MAIL_SCRIPT_NAME} in the client template but still not working.