Script to copy the value of a choice field to a reference field. Dependent values not working

carlh
Kilo Guru

Hi All,

I was asked to add subcategories to choose from that are dependent on the value of the CMDB_CI field.   I was told this is not OOB functionality so I am looking for a decent work around.

To start, I created a choice field called "Application Subcategory" and I Made it dependent on the CMDB_CI Field value.   First I chose just the field and got nothing.   Then I chose CMDB_CI.Name and that made some values but not all and not the ones I wanted.

My idea is as follows.   I will use a choice field to list the values (Business Services/App names).   When a user selects the value on the choice list, I want to copy that value in to the CMDB_CI Field.

I'm not sure if this will work but hope it will and need a script to try it.

Can someone provide an "OnChange()"   script.

Here's the pseudo script with correct field names.

"When   "u_app_subcat_choice" changes from "None" and is not empty, set "CMDB_CI" to same as u_app_subcat_choice

I need this to happen on the form while being used in order to complete the record without having to save in between.

Any ideas or thoughts on this one?

Thanks

Carl

1 ACCEPTED SOLUTION

I actually figured out a way to do this on my own!!!



As I mentioned, I am using a Reference fields as the Dependent Value.   I added a bunch of choices to the dictionary and added the Application name as the Dependent value.   It wasn't working.



So After this post and calling in an incident to support I was not getting where I hoped.   I tried the following



From the incident form I right clicked on the label of my "Application Subcategory" and chose "Configure Choices"



Using the "Enter new item:" Field at the bottom of the form, I added the choices I wanted and saved.



find_real_file.png


This worked! and When I checked the dictionary, the Dependent Value was the Sys_ID of the Application I chose.



I don't see what could be wrong in this scenario but hope someone else may.



Thanks



Carl


View solution in original post

6 REPLIES 6

I actually figured out a way to do this on my own!!!



As I mentioned, I am using a Reference fields as the Dependent Value.   I added a bunch of choices to the dictionary and added the Application name as the Dependent value.   It wasn't working.



So After this post and calling in an incident to support I was not getting where I hoped.   I tried the following



From the incident form I right clicked on the label of my "Application Subcategory" and chose "Configure Choices"



Using the "Enter new item:" Field at the bottom of the form, I added the choices I wanted and saved.



find_real_file.png


This worked! and When I checked the dictionary, the Dependent Value was the Sys_ID of the Application I chose.



I don't see what could be wrong in this scenario but hope someone else may.



Thanks



Carl


Gurpreet07
Mega Sage

Hi Carl,



It seems like you want to apply a filter on choices based on value selected in reference field. Below thread explains this for service catalog , You could give a try.


Reference Qualifier on Lookup Select Box Variable