Set default value based on other field selection

Muhammad Arif B
Tera Contributor

Hi, is there any option to set default for field B based on Field A selection other than client script or data lookup. Both fields from same table. Example

Field A u_installation = Microduct, Casing, Plaster

Field B u_charge = Company, Customer

 

When user select Field A = Microduct or Casing, Field B will auto default to Company. If user select Field A = Plaster, Field B will auto default to Customer. User still able to see both choice list on Field B

2 ACCEPTED SOLUTIONS

Juhi Poddar
Kilo Patron

Hello @Muhammad Arif B 

 

Another way to achieve this requirement is by using a UI Policy to set the default value for the field. By configuring a UI Policy, you can update Field B based on the selection in Field A, allowing it to default to the desired value. This approach is straightforward and allows for easy modification, while still giving users the ability to manually change the value if needed.

 

If you found my answer useful, I'd appreciate it if you could like it and mark it as the accepted solution. This helps others locate the solution more easily and support the community!

 

Thank You

Juhi Poddar

View solution in original post

Ehab Pilloor
Mega Sage

Hi @Muhammad Arif B,

 

You can set value using UI Policy also. If both are choice fields, then you can use Dependent value option for field B and dependent field for it would be field A. Then you can set the dependent choice values of field A in Dependent Value in dictionary of field B.

 

If you found my response helpful, please mark it as Solution and Helpful.

 

Thanks and Regards,

Ehab

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Hi @Muhammad Arif B ,

 

You can use client script to fulfill this requirement, why you need any other way for this?

 

If this solves your query, mark this as correct and helpful.

Thanks
Anand

client script doesnt support on my mobile apps currently

Eshwar Reddy
Kilo Sage

Hi @Muhammad Arif B 

Create a On change Client script on field 

if (newValue === 'Microduct' || newValue === 'Casing') {
g_form.setValue('field2', 'Company');
} else if (newValue === 'Plaster') {
g_form.setValue('field2', 'Customer');
}

Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution

 

Thanks
Eshwar



Barath P
Tera Guru

Hi @Muhammad Arif B
You can try this
https://www.servicenow.com/community/developer-forum/dependent-choice-lists/m-p/1821197

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thanks & Regards,

Barath.P