- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 03:39 PM
Hi,
How can I auto populate a reference variable in a catalog Item field using a Catalog client script?
I want to display the manager of the current logged user.
I already managed to display the current logged user info.
This is the begining of the script :
function onLoad() {
g_form.setValue('current_user', g_user.userID);
g_form.setValue('current_user_manager', ..... );
}
Thanks for any help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 05:45 PM - edited 01-30-2023 05:57 PM
You can also add default value in your reference variable to populate the manager of the logged in user:
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 05:18 PM
Hi @Mohammed Amine1 ,
As you need the details of the manager you can do it in 2 ways
1) Display BR + Client Script
2) Client Script + Script Include
According to your query I would recommend option 1
Code as below in Display BR
var user = gs.getUser();
var manager = user.manager;
g_scratchpad.manager = manager;
In your client script as below
function onLoad() {
var manager = g_scratchpad.manager;
g_form.setValue('current_user', g_user.userID);
g_form.setValue('current_user_manager',manager);
}
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2023 07:08 AM
Thank you !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 05:45 PM - edited 01-30-2023 05:57 PM
You can also add default value in your reference variable to populate the manager of the logged in user:
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2023 06:01 PM
Hello Mohammed,
You can choose two different ways to accomplish this
1) use this script Javascript:gs.getUser().getManagerID() in a default value of the manager variable
2) Old way : get the referenced value from GlideAjax and set the value [ Do let me know if you need script for the same]
Mark correct if it helped you
Regards,
Chalan