Increment the for Loop elements within the loop
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2024 12:10 PM
Hi all,
Any suggestions on the below would be much helpful
array = ['sys_id1', 'sys_id2'...]
Need to write an encoded query for each element
var query1 = "sys_id="
var query2 = ''^ORsys_id="
the final query should be with the array elements
sys_id=sys_id1^ORsys_id=sys_id2
How to achieve this via for loop or any other way?
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2024 10:44 PM
Hi @Gokul nathh.
Since you have all the sys_id in an array you can try the below code -
var array = ['sys_id1','sys_id2'];
var inc= new GlideRecord("incident");
inc.addQuery("sys_id","IN",array.join()); // This line will check if any of the sys_id is present or not in the query
inc.query();
if (inc.next()) {
//Your code
}