How to set variable checkbox true in RITM (checklist)

Sarah Anjos
Tera Contributor

Hi,
I have some RITMs that open automatically for service desk analysts to check meeting room equipment. This checklist is opened with some checkbox variables, as there are many options, the analyst requested the creation of a button or variable with the name of "Checklist ok" and when clicking, all other variables in the list must be set to true. But even doing it by client script or business rule does not work. can you help me?

find_real_file.png

If the analyst clicks on checklist ok, all previous checkbox variables should be set to "true", it didn't work with OnChange client script.

1 ACCEPTED SOLUTION

Kartik Sethi
Tera Guru
Tera Guru

Hi @Sarah Anjos 

You can create an onChange Catalog Client Script, that should observe your "Checklist OK" checkbox changes and it should have "Applies to Requested Item" checked:

find_real_file.png

In this Catalog Client Script, you can add the below-provided code:

var checkListAllFields = ['checkbox_1', 'checkbox_2', 'checkbox_3', ....];
for (var i = 0; i < checkListAllFields.length; i++) {
    //Below line will set all checkboxes to true if Checklist Ok is true
    //If False then all will be set to false
    g_form.setValue(checkListAllFields[i], newValue);
}

 


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik

View solution in original post

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hi,

Unfortunately, you didn't show us what you've used so we could help, but this can be done with an onChange client script.

You'd set the onChange client script to execute on the "Checklist Ok" variable and then in the script section, you'd use a script for example:

if (newValue == 'true') {
g_form.setValue('field_name_1', true);
g_form.setValue('field_name_2', true);
g_form.setValue('field_name_3', true);
}

That's just one way. Alternatively, you could build an array and script it like this:

var array = ['field_name_1','field_name_2','field_name_3'];
if (newValue == 'true') {
for (var i = 0; i < array.length; i++) {
if (g_form.getValue(array[i]) == 'false') {
g_form.setValue(array[i], true);
  }
 }
}

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello Allen,


Thank you so much for the help, I had done it the first way and it didn't work. But with the array it worked!

Tks

Hi @Sarah Anjos 

I'm glad you got your question answered. I'm unsure what you ended up going with as you responded to both people with a response that it worked.

Both of my methods work as I tested them myself prior to posting.

If you've marked another post as Correct, which covers the same concept that I did above that you said you've used...then please at least consider marking my reply above as Helpful, as currently it's neither helpful or correct.

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Kartik Sethi
Tera Guru
Tera Guru

Hi @Sarah Anjos 

You can create an onChange Catalog Client Script, that should observe your "Checklist OK" checkbox changes and it should have "Applies to Requested Item" checked:

find_real_file.png

In this Catalog Client Script, you can add the below-provided code:

var checkListAllFields = ['checkbox_1', 'checkbox_2', 'checkbox_3', ....];
for (var i = 0; i < checkListAllFields.length; i++) {
    //Below line will set all checkboxes to true if Checklist Ok is true
    //If False then all will be set to false
    g_form.setValue(checkListAllFields[i], newValue);
}

 


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik