Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to fetch data (asset brand and asset name) from entered user ?

Steveneg
Tera Expert

Hi Everyone, 

It is my very first post here (recommendations are always welcome) so I am sorry if it is the wrong way or not the right place for this question... Now let's get to business.

I am new to servicenow so I am not aware of all the different solutions that there might be for my problem, sorry for that.

What I am trying to achieve is: on a catalog item, 
fetch and display the name and serial number of an asset (listed on the alm_hardware table) that is assigned to a user (user is selected via a reference field on the catalog item itself). And I want to display those two values on two different basic single line text fields.

To tackle this, I guess i'll need an Onchange client script (because the values have to change everytime I change my user in the reference field. 
But I have no clue on how to fetch those values, so any help is welcome. 

Someone suggested me to use List collectors to get those values, but somehow I can't make them work... 

Please help me and thank you in advance for that.

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Take a look through this article to see if you can meet your requirements without a script.  I think this would satisfy the requirement of retrieving fields from the user table like manager, company, etc, but it's good to know anyway:

https://www.servicenow.com/community/developer-articles/catalog-data-lookup-definition-on-any-table-... 

 

To look up the asset(s) assigned to a selected user, you will need to use GlideAjax in an onChange Catalog Client Script to call a Script Include, passing in the value of the user.  Here is an excellent walk-through of how to do that.

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

 

Give this a shot and post your scripts using the insert code icon </> if you get stuck.

View solution in original post

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

Take a look through this article to see if you can meet your requirements without a script.  I think this would satisfy the requirement of retrieving fields from the user table like manager, company, etc, but it's good to know anyway:

https://www.servicenow.com/community/developer-articles/catalog-data-lookup-definition-on-any-table-... 

 

To look up the asset(s) assigned to a selected user, you will need to use GlideAjax in an onChange Catalog Client Script to call a Script Include, passing in the value of the user.  Here is an excellent walk-through of how to do that.

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet-updated/ta-p/2... 

 

Give this a shot and post your scripts using the insert code icon </> if you get stuck.