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

Perfect thank you for such a quick reply. I was missing the ^ before the model_category

 

Thanks Ankur 

Mark 

Glad to help.

Please mark response helpful

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

Suseela Peddise
Kilo Sage

Hi,

You can use reference qualifier on Assets variable.

 

Reference qualifier on Assets variable:

javascript: 'assigned_to='+current.variables.<<user variable name>>; //replace with user variable

 

If I have answered your question, please mark my response as correct and/or helpful.

Thanks,

Suseela P.

Ravindra H V
Tera Contributor

Hi ,
Firstly, @Ankur Bawiskar, thank you for providing such a simple and effective approach with the reference qualifier – it was really useful. Furthermore, I would like to propose adding an extra condition to further refine the query incase of an OR condition.
Imagine their is 2 model category then the Qualifier would be: -
javascript&colon; 'assigned_to=' + current.variables.requested_for+ '^model_category=ea34ac80db416f40d0f9b5ca689619de^ORmodel_category=abcd2345687654324567de^EQ';


Please mark it as helpful if you found this useful.
Thanks
Warm Regards
Ravindra H V