- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2017 10:40 AM
Hi All,
we have a requirement wherein we need to get all the asset's assigned to a person in an email notification.
If he has multiple assets, all the assets should be in the email.
It should be in the folowing way
"Below are the assets assigned to ${variables.assigned_to}."
Asset 1:
Asset 2 "
Can you help me in achieving this through the workflow notification
Thanks,
Kamal
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 08:29 AM
Create a Email script like below and use this mail script in the notification.
1. go to system Notification --> Email --> Notification Email Scripts
Name: user_assets
Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var gr = new GlideRecord('cmdb_ci_computer');
gr.addEncodedQuery('assigned_to', current.<user field>);
gr.query();
while(gr.next()){
template.print(gr.name+'<br/>');
}
})(current, template, email, email_action, event);
2. Go to System Notification --> Email -->Notifications
create a notification with Message Html( under 'What it will contain' tab) as below.
<add content as you wish..>
user assets are :
${mail_script:user_assets}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 08:17 AM
Hi Kamal,
You can create a mail script and use GlideRecord to 'alm_asset' table. Check the following link
Scripting for Email Notifications - ServiceNow Wiki
Thanks,
Nitin.
Hit Like, Helpful or Correct based on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 08:25 AM
Hi Nitin,
Is there a way where in we can get a solution in the workflow notification itself?
Thanks,
Kamal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 08:31 AM
No, you have to create a mail script and call the mail script from the Notification.
Thanks,
Nitin.
Hit Like, Helpful or Correct based on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 08:29 AM
Create a Email script like below and use this mail script in the notification.
1. go to system Notification --> Email --> Notification Email Scripts
Name: user_assets
Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var gr = new GlideRecord('cmdb_ci_computer');
gr.addEncodedQuery('assigned_to', current.<user field>);
gr.query();
while(gr.next()){
template.print(gr.name+'<br/>');
}
})(current, template, email, email_action, event);
2. Go to System Notification --> Email -->Notifications
create a notification with Message Html( under 'What it will contain' tab) as below.
<add content as you wish..>
user assets are :
${mail_script:user_assets}