The CreatorCon Call for Content is officially open! Get started here.

How to set the value in Configuration Item field using the data from the Question Choices

Jake Paz
Kilo Explorer

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!

 

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

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

View solution in original post

8 REPLIES 8

Thank you Vamshi. The script works!

Cheers, I'm glad it worked.

Jake Paz
Kilo Explorer

Already tried both below but still not working.

current.cmdb_ci=producer;

current.cmdb_ci=producer.cmdb_ci;

find_real_file.png

find_real_file.png

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 @Vamshi dhar script

 

Mark it as Correct if it fulfills your requirement