- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 04:00 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 05:01 AM
Create a Notification Email Script as below
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 04:12 AM - edited 07-03-2023 04:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 04:15 AM
Hello ,
Thank you for your quick response.
Could you show me an example?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 05:01 AM
Create a Notification Email Script as below
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 06:48 AM
Please Mark the response Correct and Helpful, in case it helps.