Client script to pull in users assigned assets

clivebushell
Giga Contributor

Hi, 

I am creating a new portal form for line managers to report that their employee who has left the company will be returning their equipment, so the desktop team can arrange for the equipment (laptop etc) can be returned. On the form I want to pull through the assets which the employee has assigned to them in the alm_asset table.

I am thinking that a good way to do this would be once the line manger has opened the new portal form, and completed who the equipment to be returned for in a user drop down from the sys_user table an asset drop down box will appear with the asset(s) which the person selected in the box above has.

is there a simple script I could use to do this?

 

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I consider you must be using catalog item for this; the approach looks good; just ensure both the variables are of type reference

1) user reference to sys_user table

2) assets reference to possibly alm_asset table

Ensure you add reference qualifier to the 2nd variable to show only those assets assigned to that selected user

javascript: 'assigned_to=' + current.variables.user;

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I consider you must be using catalog item for this; the approach looks good; just ensure both the variables are of type reference

1) user reference to sys_user table

2) assets reference to possibly alm_asset table

Ensure you add reference qualifier to the 2nd variable to show only those assets assigned to that selected user

javascript: 'assigned_to=' + current.variables.user;

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Amazing thank you so much 🙂 

Hi @Ankur Bawiskar 

Thanks for the above. I have an additional ask on how you can restrict the qualifier to only being of a certain model category. 

What I have done is taken you code 

javascript: + 'assigned_to=' +  current.variables.requested_for ;

And updated this to 

javascript: + 'assigned_to=' +  'model_category=ea34ac80db416f40d0f9b5ca689619de^EQ' +  current.variables.requested_for

*model_category is mobile phones

Unfortunately this returns all devices under that model and not the one that is assigned to the 'assigned_to'

Kind Regards

Mark 

Hi,

something like this

javascript: 'assigned_to=' +  current.variables.requested_for + '^model_category=ea34ac80db416f40d0f9b5ca689619de^EQ';

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader