We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Is it possible to create list type field as dependent field in servicenow task table

Praveen Kumar4
Kilo Contributor

Field 1 is list type field and field 2 is also list type field dependent on field1 ,is it possible to create such dependency?

17 REPLIES 17

Try with following configuration:

1.-On the dictionary of List 2, click on advanced view and add the following reference qualifier:

javascript: new listFilter().getDependent(current.u_list_1.getDisplayValue());

find_real_file.png

 

Just replace the 'current.u_list_1' with your name of your list 1.

 

2.-Create a script include:

var listFilter = Class.create();
listFilter.prototype = {
    initialize: function() {
    },
	getDependent: function(lists){
		var list = lists.split(", "); //its important leave a blank space after the comma
		var string = '';
		for(var i = 0;i<list.length;i++){
			string+='nameSTARTSWITH'+list[i]+'^OR';
		}
		return string;
	},

    type: 'listFilter'
};

find_real_file.png

Note: I'm using the 'nameSTARTSWITH' filter, you need to verify and replace it if necessary with the name of the field on the table of the list 2 that contains the values of T1_1,T1_2,T1_3,T2_1,T2_2,T2_3,T2_4, etc.

 

Hope it helps,

Thanks

 

Thanks for your response Alejandro RP,

There are 2 changes in our requirement

1.Field 1 in a string type field

2.Field 2 is a list type field with choices created on sys_choice table and choice name in Field 1 and field 2 are not as showed in example their names are diffaren't,like they wont have choice like Tx_* .

Ex:Field 1 = USA

Field2 = California,texas,Florida,Alaska,Arizona,Washington dc

Field1=India

Field2=Delhi,Maharashtra,Karnataka,AP,Telangana

 

In that case I would suggest the following configuration:

I don't recommend set the Field 1 as a string, I think is better make it a string with choices or a choice list, so Field 1 or Choice 1 would have choices for your contries:

find_real_file.png

Then, the Field 2 or Choice 2 would be configured as dependent field of choice 1, and on the choices, you can set the 'dependent value' field depending on the choice, note that California, Florida and Texas have 'usa' on Dependent Value: 

find_real_file.png

And the result is that on the form, if you select USA on Choice 1, the options of Choice 2 would be the choices with 'usa' on dependent field:

find_real_file.png

Hope it helps,

Thanks

Thanks for your response Alejandro RP,

But Field2 has to select multiple choices,

Field 1 = USA

Field2 = California,texas

Like this

 

Ok, 

If you want to configure the Field2 as a list referencing to sys_choice table you need to modify the dictionary of the Reference field:

find_real_file.png

Because it has an OOB filter to all the tables except sys_choice table, you would need to remove this filter.

Then create the choices for Field2 with the dependent fields (as I showed on my previous reply)

After that you can add following script on reference qualifier of Field 2 (Choice 2):

javascript:'element=u_choice_2^dependent_value='+current.u_choice_1

Note: you can make this design using a new table instead of the sys_choice table.

Hope it helps,

Thanks