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

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

DUGGI
Giga Guru

You can Access Check box variable using "producer"."check box variable name"



EX:


current.short_description += producer.test_check;


preetim
Giga Contributor

Hi,



Thanks for reply, I have added script as


if (producer.vsa_partner_forecast   == 'true')


{


current.description += 'Capacity:VSA Partner Forecast';


}



This is working fine, but there are multiple checkboxes values, so is there way to short down script like using OR statement , verify which value is checked and display only that in notes field


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];


        }


}


preetim
Giga Contributor

Thanks for help ...