Retrieve user information when opening a catalog item form

jesusnava
Giga Expert

Hello experts, I am creating a catalog item in which there is some information that needs to be loaded with any user when opening the form, could you guide me on how to retrieve any user:

*Employee Number

*Department

*Position

I have a client script in which I get the user's "user name" which is this one:

find_real_file.png

Field has been set as a single line text:

find_real_file.png

find_real_file.png

those two are working but for the other fields (Employee number, Department, position) something is not working fine, could you be so kind of guiding me?

Thank you!

1 ACCEPTED SOLUTION

OK well that is a good start, you are getting the sysid. So that is what DepartmentID is

If you now change that to say

javascript: gs.getUser().getDepartmentName();

That should return the name of the department

 

As you say these will auto populate the fields on load, which is a good thing to have. I use them a lot in my catalog items, make life easier to users.

But as you say someone might be logging a request on behalf of someone else.

 

You need to then just add these either into one total client script, or if you have the UserName one working, just copy them out into three.

1) Username on change

2) Department on change

3) Title on change

View solution in original post

6 REPLIES 6

Alexander Grisb
Kilo Guru

You would use gs.getUser(). For those other fields, if .getRecord().getValue() works, I would try that. An alternative method is to try a GlideAjax. For this in particular, a user wouldn't usually change unless they're an admin, so it would be okay to leave it on an onLoad. If it's not changing switching between impersonating users when you're testing, you should be reloading the form.

 

 

Hope this answer helped or solved your problem. If so, please mark as 'Helpful' or 'Correct'. Thanks!

Alexander

Hello Alexander, I tried the get value but all I get is the department ID, and I need it to show the name, not the id. let me keep trying. As for the client script, I need it on change since users create tickets on behalf of other users, that's why I need to get the value of the user selected in "Requested for".

Regards