- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 05:13 AM
I want to send an email which has a table in it,
Like Sl.no task description
1 TASK001 abcd
2 TASK002 xyz
How can i achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 08:10 AM
Hello Swathi,
It's my mistake that I didn't give attention that you needed it via workflow.
So, in that case my suggestion would be, creating a new event from the registry and add an Event activity in the workflow and provide the name of the Event there.
After that, from the Email->create a Notification and trigger it when the event is fired with the particular event name.
Like,
And, in the Notification body, you can include which I posted previously:
Also, you can specify the recipients from here itself.
I hope this would solve your requirement more easily rather writing a long piece of mail script and then including it in the mail body.
Please hit Like or mark Helpful or Correct based on the impact.
Thanks,
Rajshekhar Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 05:15 AM
Hi Swathi,
If the data is dynamic you need to write a notification email script to fetch and print the data in your notification.
http://wiki.servicenow.com/index.php?title=Scripting_for_Email_Notifications#gsc.tab=0
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 05:57 AM
Hi Swathi,
Below is the sample email script. Invoke this from your email notification using
${mail_script:tableData.emailScript}
email script name - tableData.emailScript;
Script
// current refers to task table here since in example you mentioned task number
template.print('<table style="width:100%">');
template.print('<tr>');
template.print('<th>Sr No</th>');
template.print('<th>Task</th>');
template.print('<th>Description</th>');
template.print('</tr>');
var taskNumbers = 'TASK123,TASK456'; // considering you know these task number information you need to include in email; you can take it from event.parm2
var count = 1;
var gr = new GlideRecord("sc_task");
gr.addQuery("number", "IN" , taskNumbers);
gr.query();
while(gr.next()) {
template.print('<tr>');
template.print('<td>'+ count +'</td>');
template.print('<td>'+ gr.number +'</td>');
template.print('<td>'+ gr.short_description +'</td>');
template.print('</tr>');
count++;
}
template.print('</table>');
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 06:31 AM
I dont want dynamic data, i want to show static data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2017 06:34 AM
Hi Swathi,
Then you can repeat the following code as per your static content:
template.print('<tr>');
template.print('<th>Sr No</th>');
template.print('<th>Task</th>');
template.print('<th>Description</th>');
template.print('</tr>');
template.print('<tr>');
template.print('<td>1</td>');
template.print('<td>TASK001</td>');
template.print('<td>abcd</td>');
template.print('</tr>');
template.print('<tr>');
template.print('<td>2</td>');
template.print('<td>TASK002</td>');
template.print('<td>xyz</td>');
template.print('</tr>');
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader