- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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).