Auto Populate Name based of another field selection

karlab
Tera Contributor

Hello,

 

I have a field name Business Unit with 3 choices (HQ, IET, OFSE). I would like the Leader field to auto populate a name based of the selection. For example,

 

If HQ is selected John Doe should be the name that's populated on the Leader field without the user being able to edit the field.

 

If IET is selected Kate Smith is the name that should be displayed/populated on the leader field without the user being able to edit.

4 REPLIES 4

Gangadhar Ravi
Giga Sage
Giga Sage

You can try Data lookup definition 

 

https://docs.servicenow.com/bundle/xanadu-platform-administration/page/administer/task-table/concept...

 

Please mark my answer correct and helpful if this works for you.

susan789wolfe
Giga Contributor

@karlab wrote:

Hello,

 

I have a field name Business Unit with 3 choices (HQ, IET, OFSE). I would like the Leader field to auto populate a name based of the selection. For example,

 

If HQ is selected John Doe should be the name that's populated on the Leader field without the user being able to edit the field.

 

If IET is selected Kate Smith is the name that should be displayed/populated on the leader field without the user being able to edit.


To accomplish this, you will need to use a combination of field dependencies and read-only settings. The specific steps can vary depending on the platform or tool you're using (such as Salesforce, Microsoft Dynamics, or a custom web application)

Mongkoll
Tera Contributor

You can use a script in the Virtual Agent topic flow to fetch the required name based on the selected field. A script action or a data lookup in the topic can help pull the correct value dynamically. If you've worked on converting an Excel spreadsheet to web app, the approach is similar—extracting and displaying data based on user input. A simple GlideRecord query should do the trick.

sanketpatil09
Tera Guru

To automatically fill the Leader field based on the selected Business Unit and make it read-only, create an onChange Client Script for the Business Unit field.

 

In the script, check the selected value and set the Leader field accordingly.

 

For example, if HQ is selected, set the Leader field to John Doe; if IET is selected, set it to Kate Smith. After setting the value, use g_form.setReadOnly('leader', true); to prevent users from editing it. Save the script and test it on your form to ensure the Leader field updates correctly when the Business Unit changes.