Catalog Auto-populate User's Manager's Info

Evan Duran
Kilo Guru

I have a catalog item that auto-populates fields based on user's logged in. If you decide to change cardholder name it will auto populate based off their record as well. My question is how to I auto populate the user's manager's TITLE, and EMPLOYEE number. These variables on their records are 'title' and 'employee_number' but my script is based off cardholders record only.

find_real_file.png

1 ACCEPTED SOLUTION

Chase Stevenson
Mega Guru

Hello, to do this, you can create 2 catalog client scripts on your catalog item and you will need an additional field for a reference to the user's supervisor. You can choose to hide this new supervisor field using a UI policy if you wish, and it will still work:
find_real_file.png

#1 client script to populate the supervisor reference:
find_real_file.png

#2 client script to populate the supervisor title:
find_real_file.png

View solution in original post

5 REPLIES 5

Mohith Devatte
Tera Sage
Tera Sage

Hello @Evan Duran ,

which table is your card holder field referring to ?is it not user table ?

and title and employee are also on user table right ?

Chase Stevenson
Mega Guru

Hello, to do this, you can create 2 catalog client scripts on your catalog item and you will need an additional field for a reference to the user's supervisor. You can choose to hide this new supervisor field using a UI policy if you wish, and it will still work:
find_real_file.png

#1 client script to populate the supervisor reference:
find_real_file.png

#2 client script to populate the supervisor title:
find_real_file.png

Exactly what I was looking for, thank you so much. I went ahead and tried this out and it worked perfect.

Allen Andreas
Administrator
Administrator

Hi,

Just to mention this for the future, the leading practice here would have been to utilize a catalog lookup definition. This eliminates the need for any scripting at all and is a very clean process to grab fields related to the user, to include their dot-walked values of manager's title, number, etc.

I'd recommend reviewing this as well: https://docs.servicenow.com/bundle/sandiego-servicenow-platform/page/product/service-catalog-managem...

So if all of those fields involved were related to the sys_user table, then the entire thing could have been handled by catalog lookup definition.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!