Show specific list of choices in List Collector field based on another field

Narmadha PR
Tera Contributor

Hi,

I have 2 fields "Request" and "Label".  "Request" is a dropdown field with 5 options and  "Label" is a list collector field with 23 options. Based on the options I'm selecting from the Request field, I want to show the choices in the list collector field.

Can you please help?

2 ACCEPTED SOLUTIONS

@Narmadha PR 

you can use this advanced ref qualifier on list collector

Ensure you give correct choice value to compare and correct sysIds of question_choice records

javascript: var query; var choice = current.variables.firstVariable; if(choice == 'choice1') query = 'sys_idINsysId1,sysId2'; else if(choice == 'choice2') query = 'sys_idINsysId3,sysId4'; query;

Ensure you add this variable attributes

ref_qual_elements=firstVariableName

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

View solution in original post

Vishal Jaswal
Giga Sage

Hello @Narmadha PR 

Taken reference from: https://www.servicenow.com/community/developer-forum/need-a-simple-onchange-client-script-to-force-l...

here is what you need to perform to achieve something like below:

VishalJaswal_0-1752166595413.png



VishalJaswal_1-1752166604101.png

 

VishalJaswal_2-1752166612846.png

VishalJaswal_6-1752166958666.png


Service portal screenshots:

VishalJaswal_7-1752167020209.png



VishalJaswal_8-1752167035139.png

 

VishalJaswal_9-1752167041886.png

 


Here are the variables:

VishalJaswal_3-1752166630569.png


Here is your List collector variable:

VishalJaswal_5-1752166944326.png

 


Reference qualifier:

javascript:
var listCollectorFilter = {
 'choice1': 'sys_idIN5e7101b697968d1021983d1e6253af4e,1f8101b697968d1021983d1e6253af4f',
 'choice2': 'sys_idINe59101b697968d1021983d1e6253af52,1ab7eafa9712cd1021983d1e6253af52',
 'choice3': 'sys_idINeda62e7a9712cd1021983d1e6253af19,09a7aafa9712cd1021983d1e6253aff6'
};
listCollectorFilter[current.variables.request] || '';


Variable Attributes: ref_qual_elements=request


Hope that helps!

View solution in original post

7 REPLIES 7

Brian Lancaster
Tera Sage

This ServiceNow Guru post has the answer. I have been using this since the Calgary release.

Hi @Brian Lancaster 

I tired similar script but got into this issue

Ankur Bawiskar
Tera Patron
Tera Patron

@Narmadha PR 

list collector is bringing choices from which table?

share screenshots of variable configuration for both

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

Hi @Ankur Bawiskar 

list collector is bringing choices from question_choice table

NarmadhaPR_0-1752159569563.png