- 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 09:09 AM
I think it would be better if he uses 'alm_asset' in the GlideRecord instead of 'cmdb_ci_computer' because they might have mobile phones too.
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 10:48 AM
Yes Nitin, Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 10:36 AM
Hi Vinod,
I have tried the same,
But it is coming as undefined
i used below code in mail script
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var gr = new GlideRecord('alm_asset');
gr.addEncodedQuery('assigned_to', current.variables.person1);
gr.query();
while(gr.next()){
template.print(gr.name+'<br/>');
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2017 10:42 AM
Hi Kamal,
Can you change the script as I have mentioned below
var gr = new GlideRecord('alm_asset');
gr.addQuery('assigned_to', current.variables.person1);
gr.query();
while(gr.next()){
template.print(gr.display_name+'<br/>');
}
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 10:53 AM
oops, typo there! Please check Nitin reply !