- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 09:59 PM
Hi All,
I have a VIT from and there are 3 detections for that VIT. We have a field 'A' in the detection form
I need to gliderecord the detection form and check the value of field 'A' for 3 records.
If any of the value is 'true' for field 'A' , I have to return the value as 'true'.
If all the values of field 'A' are false, then I have to return the value as 'false'.
How to achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 10:41 PM
Hello @User205031 -
Please give a try using below code:
var detectionFormGR = new GlideRecord('detection_form');
detectionFormGR.addQuery('A', current.sys_id);
detectionFormGR.query();
var isAnyTrue = false;
while (detectionFormGR.next()) {
if (detectionFormGR.getValue('A') == 'true') {
isAnyTrue = true;
break;
}
}
var result = isAnyTrue ? 'true' : 'false';
gs.info("Final Result: " + result);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Pratiksha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 10:19 PM - edited 03-13-2024 10:19 PM
Hi @User205031 you can do something like this though I didnot understand your requirement
var gr = new GlideRecord('detection table');
gr.addQuery('A', current.sys_id);// field A from detection table should match current table
gr.query();
var hasTrueValue = false;
while (gr.next()) {
var fieldValue = gr.getValue('A');
//has anyone record with true, then break
if (fieldValue === 'true') {
//your logic
hasTrueValue = true;
break;
}
else{
// no record with true value
}
var result = hasTrueValue ? 'true' : 'false';
gs.info('Result: ' + result);
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 10:41 PM
Hello @User205031 -
Please give a try using below code:
var detectionFormGR = new GlideRecord('detection_form');
detectionFormGR.addQuery('A', current.sys_id);
detectionFormGR.query();
var isAnyTrue = false;
while (detectionFormGR.next()) {
if (detectionFormGR.getValue('A') == 'true') {
isAnyTrue = true;
break;
}
}
var result = isAnyTrue ? 'true' : 'false';
gs.info("Final Result: " + result);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Pratiksha