
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 12:04 AM
I am wanting to do something very similar to the solution listed in the following article
What I want to do is send an email to all users that lists all assets that are assigned to them.
I'm guessing I could trigger a email notification via a business rule or an event (this is something that could be a one off or at least used only very occasionally)
I want it to go through each user, add their assets, send the email, move onto the next user, once all have been emailed stop!
The link above does not work for me as it pretty much generates an email with every single asset listed on it, nothing specific to an individual user.
Does anyone know how I can do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2020 01:46 AM
It should look like this in script
(function runMailScript(current, template, email, email_action, event) {
var user = event.parm1;
var arr = [];
var gr = new GlideRecord('cmdb_ci'); // table name changed
gr.addQuery('assigned_to', user);
gr.query();
while(gr.next()){
var str = gr.asset_tag + ' - ' + gr.name + ' - ' + gr.model_id.getDisplayValue();
arr.push(str.toString());
}
template.print('<ul>');
for(var i=0;i<arr.length;i++){
template.print('<li>' + arr[i] + '</li>')
}
template.print('<ul>');
})(current, template, email, email_action, event);
I hope this will help and answer will be marked as correct and helpful as most of the information is already shared.
Have nice day
Regards
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
‎07-28-2020 12:19 AM
Hi,
Do you require single email per user with the list of assets assigned to that user?
OR
Do you want single email per asset
Regards
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
‎07-28-2020 12:32 AM
A single email per user with the list of assets assigned to that user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 12:57 AM
Hi,
In that case you need to GlideRecord that table and group by assigned_to field
In the email script you need to get all the assets assigned to that user
Regards
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
‎07-28-2020 01:05 AM
It also doesn't tell me how to send to each user one after the other.