List field not showing choices in List View

Nicol_s2
Tera Expert

Hello,

 

Does someone knows if there is a way to display the choice list from a List field in the List view?

 

Entity view.png

I understand that if the List field is a reference, it allows you to search for the references. Is there a similar option available for choices?

It's quite inconvenient having to manually enter the name of a choice whenever you want to make a query.

 

Thanks.

 

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

No , mate it is not available. Choices and reference looks similar but are different in nature.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@Nicol_s2 

that's how OOB the list field filter works

Nothing much can be done for that

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi @Nicol_s2 ,

ServiceNow doesn't directly support displaying Choice Field options in the List View, but we can do workarounds depending on our needs:

You can take look of following method to acheive your requirements:

 

To display the choices in a List View is to create a Scripted Field that will provide the choice options for a record. This involves scripting to get the possible choices and display them as a string or in a format that can be rendered in the list.

 

  • Create a Scripted Field (String field) on the table where the Choice Field is defined.
  • In the Scripted Field, write a GlideRecord query to fetch the choice options for the choice field and display them.

Assume you have a Choice Field on a custom table (u_choice_field), and you want to display all possible options for that field in a List View.

Script:

(function execute(inputs, outputs) {

// Create a GlideRecord query to fetch choices from the 'sys_choice' table

var choiceList = [];

var gr = new GlideRecord('sys_choice');

gr.addQuery('name', 'your_table_name'); // Replace with your table name

gr.addQuery('element', 'u_choice_field'); // Replace with your field name gr.query(); // Loop through the results and add to the choiceList

while (gr.next()) {

      choiceList.push(gr.getDisplayValue('label')); // Add the choice label to the list

} // Return the choices as a comma-separated string

outputs.choiceOptions = choiceList.join(', ');

})(inputs, outputs);

 

When you add this Scripted Field to the List View, it will display the available choices for that Choice Field as a comma-separated list.