Create a choice list from a dynamic script that returns the choices

mikehall
ServiceNow Employee
ServiceNow Employee

Hi Team!

 

I want to add a field to a table containing a list of tables determined by a script.  I'm struggling to find the best way to do this.  So far, I have a Choice field and am using the Calculated Value.  I'd like to do a GlideRecord call on another table, which will give me back my list of 5-10 tablenames that I want to present in my list.  The 

calculatedFieldValue() method seems to want to only return a single string (like "incident") and not a list of tablenames to make a choice list.  See screen shot.
Screenshot 2025-02-05 at 4.38.04 PM.png


1 ACCEPTED SOLUTION

Natan F Rosa
Kilo Guru

Option 1 with interface
NatanF_Rosa_0-1738805238116.pngNatanF_Rosa_1-1738805306454.png

Option 2 with script include and GlideRecord

NatanF_Rosa_2-1738805786469.png

 


Hi Mikehall

You can create a list field type in the table and configure the table you want.
You can set up a simple filter or change it to dynamic and create an include script to make the glide in the table return the desired values.

Please mark the answer as correct if it helped in any way.

View solution in original post

5 REPLIES 5

Natan F Rosa
Kilo Guru

Hello

Do you can details more your ask?

Natan F Rosa
Kilo Guru

Hello

do you can details more your ask?

Sheldon  Swift
ServiceNow Employee
ServiceNow Employee

Hi @mikehall - What's the use case? Have you considered a reference field (referencing sys_db_object) with a dynamic reference qualifier? 

Natan F Rosa
Kilo Guru

Option 1 with interface
NatanF_Rosa_0-1738805238116.pngNatanF_Rosa_1-1738805306454.png

Option 2 with script include and GlideRecord

NatanF_Rosa_2-1738805786469.png

 


Hi Mikehall

You can create a list field type in the table and configure the table you want.
You can set up a simple filter or change it to dynamic and create an include script to make the glide in the table return the desired values.

Please mark the answer as correct if it helped in any way.