The CreatorCon Call for Content is officially open! Get started here.

Increment the for Loop elements within the loop

Gokul nathh
Tera Contributor

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

Anirudh Pathak
Mega Sage

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
}