email client template - how to use a dynamic FROM value?

Zod
Giga Guru

Hi All,

as I learned the hard way, just using mail scripts in the body (that will derive the proper from and reply_to values) will not work  

But ok ... for the reply to I can use some easy js like "javascript:current.assignment_group" .... BUT how to go ahead with more complex script which I need to define the FROM field?????

PLEASE HELP.

Best would be to be able to add a email script .. but this does not work (tried like in the body with ${mail_script:abc_scipt_client}

1 ACCEPTED SOLUTION

You can write a script include and call the script include in the java script. in script include, you can include the validation of assignment group.



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

View solution in original post

21 REPLIES 21

can you change the notification email script to and remove anythingelse



gs.log('+++++++++++++inside cms_test_form notification script+++++++++++++++++');


email.setFrom("abc@xxxxx.com");



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

as scoped app - i use gs.info 😉 .. log does not work as far i know ...



New log is now bigger ,-)


log2.JPG


Looks like ail script doesnt work. See if the below option works for you.



http://wiki.servicenow.com/index.php?title=Enabling_the_Email_Client#Creating_Email_Client_Templates


4.6.1 Setting the From Address with an Email Client Template

Use an email client template to set a default value for the From field if it should be different from the system default. For example, you can dynamically set the From field to the email address of the current user.


  1. Navigate to System Policy > Email > Client Templates.
  2. Select an existing template or create a new one. For example, select the Incident Template record.
  3. Configure the form to add the From field.
  4. Enter a script to add a default value to the From field.

For example, the following script displays the current user name and the current user email address.


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

The email client dynamically generates the email address, as shown.



Email client displays values based on the email client template




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

.. this is not working for me as I need to validate an assignement_group field as well as some sys_user fields to derive the from field as well as having some possible fallbacks to be taken care of ... how can I add this (like new GlideRecord validations) after the "javascript:" ? I do not understand the syntax if the code is longer than just current.assigne.to ....


You can write a script include and call the script include in the java script. in script include, you can include the validation of assignment group.



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