using a Client Script

AdithyanS
Giga Contributor

There are two fields, Requested For and Manager, in two separate application tables. When I select a user in the Requested For field, the Manager field should automatically populate with that user's manager and become read-only. How can I implement this in ServiceNow using a Client Script?

1 ACCEPTED SOLUTION

Tanushree Maiti
Tera Patron

 

Hi @AdithyanS 

 

You can use an onChange Client Script on the Requested for field along with GlideAjax, passing the selected Requested for user's value to a Script Include. In the Script Include, you can use GlideRecord to retrieve the manager from the relevant table based on the selected user and return the result to the Client Script.

 

View solution in original post

2 REPLIES 2

Tanushree Maiti
Tera Patron

 

Hi @AdithyanS 

 

You can use an onChange Client Script on the Requested for field along with GlideAjax, passing the selected Requested for user's value to a Script Include. In the Script Include, you can use GlideRecord to retrieve the manager from the relevant table based on the selected user and return the result to the Client Script.

 

While Tanushree's response correctly explains how to fetch and populate the manager, make sure to include g_form.setReadOnly('manager', true); inside your Client Script callback function to fulfill the second part of your request (making the Manager field read-only).