How to populate manager name on request form?

chrish5
Giga Guru

I have the below onLoad catalog client script to populate fields on my request form.   The "Name' field is populating fine, but the manager field where I'm trying to just pull in their name is not and looks like this.   What am I doing wrong?  

 

chrish5_0-1678805055033.png

 

 

function onLoad() {
var reqf = g_form.getReference('requested_for',getInfo);
}
function getInfo(reqf)
{
g_form.setValue('name', reqf.name);
g_form.setValue('manager', reqf.manager.name);
g_form.setValue('department', reqf.department);
}

1 ACCEPTED SOLUTION

Hi,

 

Please follow the below link for an example :-

 

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430

 

Hopefully this is a good start.

 

Regards,

Dhruv

View solution in original post

7 REPLIES 7

Dhruv Chandan
Giga Guru

Hi,

 

Using "getReference" is not a best practice.

 

I would suggest you to use a combination of client script and script include to populate these values.

 

Should you need help with script let me know.

 

Hope this helps

 

Regards,
Dhruv

Hi Dhruv,

Thank you for your suggestion.  Could you please provide and example of what these scripts would look like.  

Thanks,

Chris

Hi,

 

Please follow the below link for an example :-

 

https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430

 

Hopefully this is a good start.

 

Regards,

Dhruv

Community Alums
Not applicable

Hi @chrish5 ,

 

You have to use GlideAjax API to get the manager name populated in the field as you have this data at the server side.

 

Following link will help you achieve what you are looking for

1. https://www.servicenow.com/community/itsm-forum/set-manager-name-based-on-selected-user/td-p/628461

 

Probably you need to modify the script include slightly to achieve what you are looking.

 

Please mark helpful/like if the solution is in line with your expectation.

 

Regards,

Gagan k