Announcement : Email Template

C_S3
Tera Contributor

Hello Everyone,
I have an requirement, when someone is creating an announcement then email should be send. I have created one notification and one email template, both on announcement table. Now in the emails signature the name and title of should be visible who created the announcement.
I tried from the fields but its not working. when I take name and title, it pull up the data from announcement table. And when i tried created by in the place of name, it pulled up the used_id.
Any help would be appreciated. Thank you!

1 ACCEPTED SOLUTION

Create a Notification Email Script as below

Screenshot 2023-07-03 at 5.27.46 PM.png

Pasting the piece of code here 

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', current.sys_updated_by); // You can use sys_created_by as well
gr.addActiveQuery();
gr.query();
if (gr.next()) {
    template.print('Name: ' + gr.name + '\nTitle: ' + gr.title);
}

 

Call this email script in you Notification body using the syntax

{$mail_script:getUserSignature}

View solution in original post

6 REPLIES 6

AirSquire
Tera Guru

You can use Notification Email Script for your use case.

 

In it you can use GlideRecord Queries to get the user record by the user_id (which you already have).

And then user template.print() to print the Name and Title of the user.

C_S3
Tera Contributor

Hello ,
Thank you for your quick response. 
Could you show me an example?
Thank you!

Create a Notification Email Script as below

Screenshot 2023-07-03 at 5.27.46 PM.png

Pasting the piece of code here 

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', current.sys_updated_by); // You can use sys_created_by as well
gr.addActiveQuery();
gr.query();
if (gr.next()) {
    template.print('Name: ' + gr.name + '\nTitle: ' + gr.title);
}

 

Call this email script in you Notification body using the syntax

{$mail_script:getUserSignature}

Please Mark the response Correct and Helpful, in case it helps.