How to get Check box field label instead of true or false

vijay39
Giga Expert

Hi guys,

I created a record producer on Request table. In that record producer, there are 10 check boxes, and the same 10 check boxes I created in request table, so that the values reflects here also in request table. Now my requirement is if the end-user selects 8 check boxes then usually in the request table the 8 check boxes will be checked. But in catalog task table I want all the 8 values in a single field with comma separated. Please note I want check box labels with comma separated. Like check boxes are USA, Australia, India etc.. I want them to be in a single field with comma separated in catalog task table. Please someone help me here. This is urgent requirement

 

Regatds,

Vijay

1 ACCEPTED SOLUTION

I believe you should create a field(always hidden) on RP to store this resultant string. If it is ok for you, then the following answer works for you.

//onSubmit Catalog Client Script

var arr = [];
var res='';
if(g_form.getValue('cbox_1'))
arr.push(g_form.getLabel('cbox_1'));
if(g_form.getValue('cbox_2'))
arr.push(g_form.getLabel('cbox_2'));
''
''
''
if(g_form.getValue('cbox_8'))
arr.push(g_form.getLabel('cbox_8'));
for(var i=0;i<arr.length;i++)
{
res += arr[i];
}
g_form.setValue('your_new_hidden_string_field',res);


//But in order to hide this field all the time, you should mention the below line in every Client Script written on that RP
//Line of code to be written in isLoading part

g_form.setDisplay('your_new_hidden_string_field',false);
//Mark sure this newly created field is mapped to 'String' field in Request table

Hope this helps!!

Thanks,

Archana

View solution in original post

8 REPLIES 8

Harsh Vardhan
Giga Patron

Hi Vijay

 

 

either by getLabel() or doing glide record on "item_option_new" table you will get the checkbox variable name

kindly refer the thread below.

 

https://community.servicenow.com/community?id=community_question&sys_id=e5c643a5db1cdbc01dcaf3231f96...

 

https://community.servicenow.com/community?id=community_question&sys_id=05aa872ddb5cdbc01dcaf3231f96...

Hi Harshavardhan,

 

Can you explain me in detail please? and where i have to write the code?

 

 

 

Regards,

Vijay

vijay39
Giga Expert
Hi Harshavardhan Thanks for responding.i will try this and get back to you

Archana Reddy2
Tera Guru

Hi Vijay,

How are you creating record in  catalog task table? Is it created after record creation in Request table?(using BR)?