Auto-populate list collector values based on another select box variable

Koyel Guha
Tera Contributor

Hi,

I have variable A (selectbox) and variable B(list collector). When I select any option from variable A for eg. "x1" then variable B referencing a customized table having a field u_description which will filter u_description contains "read" keyword and u_description contains "x1". Based on the condition, it will display the one or multiple results from the table in the varible B.

 

I have tried with a ref qual in the variable B but it is not working based on the selection.

 

javascript:"u_descriptionLIKEread^u_descriptionLIKE"+current.variables.please_select_the_fileserver_where_the_shared_folder_is_located;

 

Would appreciate your help on this.

 

Thanks.

 

9 REPLIES 9

Nilesh Pol
Tera Guru

@Koyel Guha Thecurrent.variables.X won't work in a reference qualifier directly from a catalog item. Since you're in a catalog item, you need to use a Catalog Client Script to dynamically build the reference qualifier for Variable B. 

posible solution:

Create a onchange catlog client script on variable ' fileserver' and verify the below script:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var filter = 'u_descriptionLIKEread^u_descriptionLIKE' + newValue;
g_form.setReferenceQual('shared_folder_list', filter);
}

You can Replace fileserver and shared_folder_list with your actual variable names.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Koyel Guha 

are you sure you want to use AND or you want to use OR

since 2nd variable is list collector you should use this in variable attributes so that it knows the value of 1st variable

ref_qual_elements=please_select_the_fileserver_where_the_shared_folder_is_located

AnkurBawiskar_0-1747222876054.png

 

If you want to use OR condition then use this

javascript:"u_descriptionLIKEread^ORu_descriptionLIKE"+current.variables.please_select_the_fileserver_where_the_shared_folder_is_located;

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,

Thanks for the response.

 

I need to consider AND so that it filters read keyword in the description with the file server name selected from the above variable.

 

I have tried the way you mentioned but it did not work.

@Koyel Guha 

it should work, share screenshots of your variable config

select box choices values? share screenshots

Do you have records matching that filter? did you verify 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