How to check in array has more then one value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 10:53 PM
Hi Team,
I am storing value in array and I have to check array has more then one value.
If array has only one value then I have to store value in choice field but If array has more then value then I have to store in list collector.
var asm = new GlideRecord('asmt_metric_result');
asm.addQuery('metric.name','Improvement');
asm.addQuery('instance',current.sys_id); //
asm.query();
while(asm.next()) {
arr.push(asm.string_value +",");
}
How can I check array has more then one value or one value and store according validation?
Please help me here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 11:01 PM - edited ‎01-09-2024 11:01 PM
Hi @lucky24
Use arr.length>1 to check if it has more than 1 value
Regards,
Piyush Sain

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 11:04 PM - edited ‎01-09-2024 11:05 PM
Hi @lucky24 you can use length() method to see how many values are present in array.
arr.length --> this will give you the total array values, so you can check arr.length>1 // to check more than one value
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 11:07 PM
Hi,
You can use if(arr.length>1){}