Auto populate Manager in reference field

Mohammed Amine1
Tera Contributor

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.

1 ACCEPTED SOLUTION

Saloni Suthar
Mega Sage
Mega Sage

Hi @Mohammed Amine1 

You can also add default value in your reference variable to populate the manager of the logged in user:

 

saloni1_0-1675130240232.png

 

 

 

 

 

 


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

View solution in original post

14 REPLIES 14

Hi @Ankur Bawiskar ,

In this case don't have any 

is still Catalog Data lookup definitions  possible?

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Shivam_Tripathi
Mega Guru

Hi @Mohammed Amine1 

Simplest Way

Use this in a default value of the manager Variable.Auto Populate Manager .png

If my response helped please mark it correct.

Shivam Tripathi

 

Shivam_Tripathi
Mega Guru

Hi @Mohammed Amine1 ,

Simplest way,

Use this script in default of manager varibale.

Auto Populate Manager .png

Pavankumar_1
Mega Patron

Hi @Mohammed Amine1 ,

have you tried my solution with client script?

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Yes I tried the GlideAjax .. It's working but I find te one with the javascript in default value easier.

 

Is there a best practice or a solution that performs better between client script (GlideAjax or GlideRecord) and the default value reference ?

 

Thanks.