need help in creating report which shows assets assigned to users

karan15
Tera Contributor

in servic enow for some users its showing they have been assigned 2 or more mobile phones , ideally it should be only 1 

I want to run report and find out those active users who have multiple mobile phones assigned to them so that we can contact them and update status of these phones in CMDB 

 

Please help in query and table i need to use to create this report 

 

thanks 

7 REPLIES 7

thanks Swapna , i tried using the script but didnt work for some reason can you please share more steps as in there to use this script etc ?

@karan15 

Did you create a client callable script include to find the users who are assigned to multiple assets? Then You can call this script include directly in the report filter. 

Very helpful, I tweaked mine for the script to only show In use assets, loads much quicker

 

var multipleAssets = Class.create();
multipleAssets.prototype = Object.extendsObject(AbstractAjaxProcessor, {

mAssets: function() {
var duplicates = [];
var ga = new GlideAggregate("alm_asset");
ga.addEncodedQuery("install_status=1^model_category.name=Cell Phone");
ga.addAggregate('COUNT', "assigned_to");
ga.groupBy("assigned_to");
ga.addHaving('COUNT', '>', 1);
ga.query();
while (ga.next()) {
duplicates.push(ga.assigned_to.toString());
}
return duplicates;
},

type: 'multipleAssets'
});