email recipient name in email body .

bala_1312
Tera Contributor

how to get  email recipient name in email body .

6 REPLIES 6

BharathChintala
Mega Sage

@bala_1312 

 

it is easy as if you are doing this through triggering event and select event parm1 and parm2 as recipient's. Then add email script  inside write

template.print(event.parm1);

template.print(event.parm2);

 

And call that email script in message body.

 

If notification is triggering on insert or update on record and recipient's is from fields(for example assigned to and requester are recipient's )

 

add those fields in body like reciepients - ${assignted_to.email},${requested_for.email} // these will change based on your field backend names

 

If it is hard coded group or users hard code them in body also

 

If it is complicated write email script and recipient's list with you logic and call email script in body.

 

If you want can help with any script.

 

Thanks,

Bharath

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

hi @BharathChintala ,

thanks fo rthese help , i have on more query like - i need to send mail to all user individually , which i am getting from catalog form variables(type list collector) so when i am getting the values its sending mail to everyone at a time , i need to send mail one by one . below is my script ..


var arry = [];
arry = [current.variables.{variable_name}];
for (var i = 0; i <= arry.length; i++) {
gs.eventQueue('{event_name}', current, arry[i]);
}

}

 

please advise

 

@bala_1312  replace this

var  list = current.variables.variable_name;

var all = list.split(',');

for (var i = 0; i <= all.length; i++) {
gs.eventQueue("EventName",current,all[i], "");
}

 

Thanks,

Bharath

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

Basheer
Mega Sage

Hi @bala_1312 

Use the below link to do it in a dynamic way to as many people at a time upon your requirement.

https://www.servicenow.com/community/developer-forum/use-recipient-s-name-in-email-notification/m-p/...

 

If you are triggering it via events then you can pass it as a parameter and use it in email scripts

Event trigger : gs.eventQueue("EventName",grObj,"input1@gmail.com", "input2@gmail.com");

 

This will be auto added to your message body, in message body you need to write below syntax and call email script

${mail_script:scriptName}

 

In email script

template.print(event.parm1); // this will give you input1@gmail.com

template.print(event.parm2); // this will give you input2@gmail.com

 

This will be auto added to your message body, in message body you need to write

${mail_script:scriptName}

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.