Choice Field table depending on Type Field

ican
Tera Contributor

Use Case:

 

I have a custom table (u_custom_choice) that is a Choice table for 2 Choice Field on a form which is Fruit Choice Field and Vegetable Choice Field.

 

I want to display choice on the Fruit Choice Field having type of Fruit and Vegetable Choice Field having type of Vegetable.

 

Custom Table

Name: Apple Type: Fruit

Name: Orange Type Fruit

Name: Carrots Type: Vegetable

Name: Cabbage Type Vegetable

1 ACCEPTED SOLUTION

Akshay Gupta2
Kilo Sage

Hi @ican 

 

To achieve this in, you can utilize a Choice List field type for both "Fruit Choice Field" and "Vegetable Choice Field" on your form. You would then associate each Choice List field with its respective Choice Table (u_custom_choice), filtering the choices based on the 'Type' column in the u_custom_choice table.

Here's a step-by-step guide on how to set this up:

1. **Create the Choice Table (u_custom_choice):**
- Create a new table named "u_custom_choice" with the following fields:
- Name: Text field to store the name of the fruit or vegetable.
- Type: Choice field to specify whether it's a fruit or vegetable.

2. **Populate the Choice Table:**
- Populate the "u_custom_choice" table with entries for fruits and vegetables, specifying the appropriate type for each entry.

3. **Modify the Form:**
- Edit the form where you want to display the "Fruit Choice Field" and "Vegetable Choice Field".

4. **Add Choice List Fields:**
- Add a Choice List field for "Fruit Choice Field" and "Vegetable Choice Field".
- For each field, set the 'Choice Table' to "u_custom_choice".
- Apply a filter to each field to display only fruits for the "Fruit Choice Field" and only vegetables for the "Vegetable Choice Field".

5. **Apply Filters:**
- For the "Fruit Choice Field":
- Create a filter condition to show only entries from "u_custom_choice" where Type is 'Fruit'.
- For the "Vegetable Choice Field":
- Create a filter condition to show only entries from "u_custom_choice" where Type is 'Vegetable'.

6. **Save and Test:**
- Save your changes to the form and test it to ensure that the correct choices are displayed based on the type (fruit or vegetable) selected.

By setting up Choice List fields and associating them with the "u_custom_choice" table while applying filters based on the 'Type' column, you can achieve the desired behavior of displaying fruit choices in the "Fruit Choice Field" and vegetable choices in the "Vegetable Choice Field".

 

Do give a thumbs up if this works for you.

 

Regards,

Akshay

View solution in original post

3 REPLIES 3

M Ismail
Tera Guru

Hi @ican,
Check this it will solve your problem.
https://www.servicenow.com/community/developer-forum/dependent-choice-lists/m-p/1821197

https://www.servicenow.com/community/developer-forum/dependent-field/m-p/1604824/page/2

Please hit helpful and accept this as a solution if it solved your problem.
Thank you!

Abhishek T1
Tera Contributor

Hello @ican,

 

You can refer this link for your use case. 

 https://www.youtube.com/watch?v=jiR4DjpmlRM&t=217s&ab_channel=BasicoServiceNowLearning

 

Regards

Abhishek Thombare

In this video dependency between two field has been created which will let you know that how the configuration of dependent choice list has be done in servicenow. I hope this video help you to understand the required topic i.e. dependent choice list servicenow. Please do not forget to like, share

Akshay Gupta2
Kilo Sage

Hi @ican 

 

To achieve this in, you can utilize a Choice List field type for both "Fruit Choice Field" and "Vegetable Choice Field" on your form. You would then associate each Choice List field with its respective Choice Table (u_custom_choice), filtering the choices based on the 'Type' column in the u_custom_choice table.

Here's a step-by-step guide on how to set this up:

1. **Create the Choice Table (u_custom_choice):**
- Create a new table named "u_custom_choice" with the following fields:
- Name: Text field to store the name of the fruit or vegetable.
- Type: Choice field to specify whether it's a fruit or vegetable.

2. **Populate the Choice Table:**
- Populate the "u_custom_choice" table with entries for fruits and vegetables, specifying the appropriate type for each entry.

3. **Modify the Form:**
- Edit the form where you want to display the "Fruit Choice Field" and "Vegetable Choice Field".

4. **Add Choice List Fields:**
- Add a Choice List field for "Fruit Choice Field" and "Vegetable Choice Field".
- For each field, set the 'Choice Table' to "u_custom_choice".
- Apply a filter to each field to display only fruits for the "Fruit Choice Field" and only vegetables for the "Vegetable Choice Field".

5. **Apply Filters:**
- For the "Fruit Choice Field":
- Create a filter condition to show only entries from "u_custom_choice" where Type is 'Fruit'.
- For the "Vegetable Choice Field":
- Create a filter condition to show only entries from "u_custom_choice" where Type is 'Vegetable'.

6. **Save and Test:**
- Save your changes to the form and test it to ensure that the correct choices are displayed based on the type (fruit or vegetable) selected.

By setting up Choice List fields and associating them with the "u_custom_choice" table while applying filters based on the 'Type' column, you can achieve the desired behavior of displaying fruit choices in the "Fruit Choice Field" and vegetable choices in the "Vegetable Choice Field".

 

Do give a thumbs up if this works for you.

 

Regards,

Akshay