- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 04:36 AM
Hay i have two or more Checkboxes on a form. If one of these boxes are checked, the record has to change the state ......
if i use:
var check1 = g_form.getValue('u_br_used');
var check2 = g_form.getValue('u_script_include_used');
var check3....
if (check1 == 'true' || check2 == 'true') {}
it works!
If i use
if ((check1 || check2) == 'true') {}
an only Checkbox2 ist checked it does not work...
why?
i only want to check if one of the boxes is checked and i dont want to write
check1 == 'true' || check2 == 'true' || check3 == 'true' || check4 == 'true' || .....
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 05:13 AM
Hi,
The if statement requires expression to evaluate
when you say check1 it is just a value but when you say check1 == 'true' it is an expression which it would evaluate to either true/false
https://www.w3schools.com/js/js_if_else.asp
https://www.javatpoint.com/javascript-if
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 02:08 AM
If it is a script include, we have to use
objectname.getValue('checkbox_field_name')==true