List of users who have 2 or more Assets assigned

riaz_mansuri
Kilo Guru

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

1 ACCEPTED SOLUTION

Swapnil Soni1
Giga Guru

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

find_real_file.png

 

Please mark correct or helpful.

Thanks

View solution in original post

12 REPLIES 12

Jaspal Singh
Mega Patron
Mega Patron

Hi Riaz,

 

Follow below steps.

1. Create a Script include: getassetsforusers

find_real_file.png

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

    findUserswithMoreThan1Assets: function() {
        var count = 0;
        var myGroups = [];
        var assetsare = '';
        var grusersare = [];
        var assetis = new GlideRecord("sys_user");
        assetis.query();
        while (assetis.next()) {
            assetis = assetis.sys_id + '|' + assetis;
        }
        grusersare = assetis.split('|');
        for (var i = 0; i < grusersare.length; i++) {
            var idis = grusersare[i].toString();
            var moreassets = new GlideRecord("alm_hardware");
            moreassets.addQuery("assigned_to", idis);
            moreassets.query();
            if (moreassets.getRowCount() > 1) {
                myGroups.push(idis.toString());
                count++;
            }
        }
        return myGroups;
    },

    type: 'getassetsforusers'
});

Once done create a report on User Table as below.

find_real_file.png

Thanks Jaspal, I will give this a try later and update. 

Hi Jaspal.

I still get 0

I added the script here:

find_real_file.png

Then tried this report:

find_real_file.png

javascript: new
getassetsforusers().findUserswithMoreT
han1Assets()

I do have a lot of people with more than 1 asset.

Any ideas?

Thanks