How to populate values in multi line text variable based on the checkbox selection

Sai vsk
Tera Expert

Hi Experts,

 

I am having 6 checkbox variables(A,B,C,D,E,F). Based on the check box selection, Whatever selected should populate in multiline text field. suppose if checkbox 'A' and C' selected A,C should populate in the multiline field. Likewise based on the selections, it should populate in the field. How to achieve this using client script?

4 REPLIES 4

Sagar Pagar
Tera Patron

Hi @Sai vsk,

 

Is multi-line text field on RITM form? Can you share some screenshots here?

 

If t is on RITM form, you can try the below scripts in workflow run scripts activity:

var str = "";

if (current.variables.chec_box1 == true) {
	str += "checkbox1" + "\n";
}

if (current.variables.chec_box2 == true) {
	str += "checkbox2" + "\n";
}

if (current.variables.chec_box3 == true) {
	str += "checkbox3" + "\n";
}

if (current.variables.chec_box4 == true) {
	str += "checkbox4" + "\n";
}

if (current.variables.chec_box15 == true) {
	str += "checkbox5" + "\n";
}

if (current.variables.chec_box6 == true) {
	str += "checkbox6" + "\n";
}

current.multilinetextfield = str;

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Hi @Sai vsk,

 

If it is variable on catalog form, you need to create onsubmit catalog client scripts.

var str = "";

if (g_form.getValue('chec_box1') == true) {
	str += "checkbox1" + "\n";
}

if (g_form.getValue('chec_box2') == true) {
	str += "checkbox2" + "\n";
}

if (g_form.getValue('chec_box3') == true) {
	str += "checkbox3" + "\n";
}

if (g_form.getValue('chec_box4') == true) {
	str += "checkbox4" + "\n";
}

if (g_form.getValue('chec_box5') == true) {
	str += "checkbox5" + "\n";
}

if (g_form.getValue('chec_box6') == true) {
	str += "checkbox6" + "\n";
}

g_form.setValue('multilinetextfield', str);

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar 

The world works with ServiceNow

Hi @Sai vsk,

 

Have you looked at my comments? Let me know if have any queries.


If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Samaksh Wani
Giga Sage
Giga Sage

Hello @Sai vsk 

 

You need to use onChange Client Script.

 

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading)
    return;

    if (newValue) {

         if (newValue != oldValue) {
           newValue=newValue + ',';
           g_form.setValue('multi-line-field', newValue);
          }

    }

}

 

 

 

Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.

 

Regards,

Samaksh