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

jesusnava
Giga Expert

I already have this in irder to get the user's title (Position)

find_real_file.png

the issue is that it does not change when the user changes, it loads the current user but does not change if I change the user, for this I need the client script.

Thanks

Daniel O_Connor
Kilo Guru

So the getUserName() works because it is a GlideRecord in the system.

 

Try this to see if it returns the Department

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

Then hopefully this will work to get their job title

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

If memory serves this use to not work, but I think it does now as you can dotwalk through the getUser() Gliderecord to call other fields from the User table/record

Hello Daniel, for the title I got it, see my previous post, for the department, this is what I get using what you suggested:

find_real_file.png

Also what I need is to have a client script to change those values if I change user as well, not just the one loading the form.

Regards

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