Setting scripted from address for email client template

Avik3
Giga Contributor

Hi,

I have a requirement to set email from address dynamically while a user is sending quick mails from a certain form.

Eg, We have a case form from where user is sending a mail. Depending upon the country of the user the email from address needs to be set.

I have gone to Email Client Templates, selected a template, went to sender configuration, changed From generation type to - Script. There I can see a 'script for from' section. I would like to know of the parameters this script section takes and how it returns the email address. Any sample code would also do. Thanks,

 

 find_real_file.png

Thanks,

Avik

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Avik

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

If not, please let us know if you need some more assistance.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

try this

var userRec = gs.getUserID();

var rec = new GlideRecord('sys_user');

rec.get(userRec);

if(rec.country.name == 'India'){

answer = 'your email id';

}

else{

answer = 'your another email id';

}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@Avik

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.

If not, please let us know if you need some more assistance.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Tim Grindlay
Kilo Sage

Old post but it looks like the script expects you to return a record from the 

sys_email_client_from_address table which is the same table used in the 'select from list' option. An alternative is to use the text option and the javascript: prefix to call a function that returns the address you need.