Is it possible to create list type field as dependent field in servicenow task table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2020 01:44 PM
Field 1 is list type field and field 2 is also list type field dependent on field1 ,is it possible to create such dependency?
- Labels:
-
Instance Configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2020 12:21 PM
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());
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'
};
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 10:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 12:06 PM
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:
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:
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:
Hope it helps,
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 12:11 PM
Thanks for your response Alejandro RP,
But Field2 has to select multiple choices,
Field 1 = USA
Field2 = California,texas
Like this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2020 12:55 PM
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:
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