- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 09:12 AM
Hi,
Does anyone know of a quick way we can report on users who have 2 or more assets assigned to them?
I can get a list of the users but just to know who have 2 or more assets.
Any ideas? What is the best way?
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 01:17 AM
Hi,
To get it to work your source table isUsers [sys-user] and under related list conditions select Asset -> Assigned to and change the Greater than or Equal to to 2
Hope this helps
Please mark correct or helpful.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 01:31 PM
Name of Script include should be: getassetsforusers & not one that you have used. Since name is different it is causing issues.
Change the script include name to getassetsforusers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 12:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 01:00 AM
Hi,
try below
var getassetsforusers = Class.create();
getassetsforusers.prototype = Object.extendsObject(AbstractAjaxProcessor, {
findUserswithMoreThan1Assets: function() {
var arr = [];
var user = new GlideRecord('sys_user');
user.query();
while(user.next()){
var gr = new GlideRecord('alm_hardware');
gr.addQuery('assigned_to', user.sys_id);
gr.query();
if(gr.getRowCount() >=2){
arr.push(user.sys_id.toString());
}
}
return arr.toString();
},
type: 'getassetsforusers'
});
Mark ✅ Correct if this solves your issue and also mark 👍 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
06-19-2020 01:08 AM
Above was executed from my end & it fetched results. Can you change
if (moreassets.getRowCount() > 1) {
to
if (moreassets.getRowCount() > 0) {
once for a check.
Also, ensure you have users with more than 1 or more than 1 assets in system.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2020 01:17 AM
Hi,
To get it to work your source table isUsers [sys-user] and under related list conditions select Asset -> Assigned to and change the Greater than or Equal to to 2
Hope this helps
Please mark correct or helpful.
Thanks