Script for checkboxes in Record Producers

preetim
Giga Contributor

In Record producers we have checkbox   question as below

Capacity Sheet is Label and below values as checkboxes.

find_real_file.png

We want to map these checkboxes values in script section of Record Producers so it reflects in Notes field of Incident.

How can we do that. Please suggest

1 ACCEPTED SOLUTION

You can loop through all the check boxes with a condition inside the loop to check if the check box is true.



var checkBoxVariables = [];


checkBoxVariables[0] = 'check_box_variable_1';


checkBoxVariables[1] = 'check_box_variable_2';


checkBoxVariables[2] = 'check_box_variable_3';


checkBoxVariables[3] = 'check_box_variable_4';



var checkBoxLabels = [];


checkBoxLabels[0] = 'check_box_label_1';


checkBoxLabels[1] = 'check_box_label_2';


checkBoxLabels[2] = 'check_box_label_3';


checkBoxLabels[3] = 'check_box_label_4';



for(var i=0; i<checkBoxVariables.length; i++) {


        if(producer[checkBoxVariables[i]] == 'true') {


                            current.description += '\n' + checkBoxLabels[i];


        }


}


View solution in original post

5 REPLIES 5

jussiaho
Kilo Contributor

Hi,

Can`t get this work and I think it is related to how to assign the variable to checkBoxVariables correctly.

I thought it would be just like this:

checkBoxVariables[0] = producer.<variable_name>;

But it does not work.

Can you help a bit and Servicenow instance is Istanbul if any relation to that.

At least if I just do like this:

current.description = producer.<variable_name>; // Select Box -> returns -> True

 

Br,

Jussi