- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 12:22 AM
Hi Everyone,
How do I set the value of the Configuration Item field using the data from the selection in the Question Choices?
I have selected the "WIRELESS" in the question choices and I have set the variable to map it to the Configuration item but still not working.
Can an onChange script archive this requirement as well? Please help. Thank you!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 01:43 AM
Please use this below code snippet:
var congItem = producer.getValue('variable name');
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name',congItem);
gr.query();
if(gr.next()){
current.cmdb_ci = gr.getUniqueValue();
}
Remove Map to field option for your variable as your populating CI with the script.
Mark it as Correct if it fulfills your requirement
Thanks
Vamshidhar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 02:15 AM
Thank you Vamshi. The script works!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 02:34 AM
Cheers, I'm glad it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 01:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2020 02:02 AM
Did you uncheck the map to field on the cmdb_ci variable..
if the variable is reference type field , you can use - current.cmdb_ci=producer.cmdb_ci;
if the variable is select box type field, you can write the below script
if the question choice value contains the same name of the CI in Cmdb_Ci table
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name',producer.cmdb_ci);
gr.query();
if(gr.next()){
current.cmdb_ci = gr.getUniqueValue();
}
if the Question choice value doesnt have the same name as in the CI you can refer to
Mark it as Correct if it fulfills your requirement