Continuation of script to next line

aarav
Kilo Contributor

Hi Friends.

I have to close many Incidents . i am doing it by script by hardcoding them.

Like

var chn = new GlideRecord('incident');

chn.addQuery('number','IN','INC0051502,INC0051172,INC0051088,INC0051334');   like this i have to provide some 500 incidents.

The above statement is working for 4 incidents.But how to hardcode 500 incidents .

Like

chn.addQuery('number','IN','INC0051502,INC0051172,INC0051088,INC0051334',                                                                                                    

INC0051502,INC0051172,INC0051088,INC0051334,INC0051502,INC0051172,INC0051088,INC0051334,

INC0051502,INC0051172,INC0051088,INC0051334');

The above statement is showing error as i not providing end of line and start of line symbols/commands ..

Please let me know how to continue to next line.

Thank you very much in advance.

regards

Aarav

13 REPLIES 13

Hi Aarav,



Glad it helped Please mark the answer correct and close this thread.



How To Mark Answers Correct From Community Inbox


Hi dan.bruhn



can you please help aarav to mark the answer correct and close this thread ?


Dave Smith1
ServiceNow Employee
ServiceNow Employee

Although this has been answered, one option that wasn't explored was to create an array of the incident numbers then loop through them, parsing each one.



It may be more process-intensive, but it looked like the objective here was to make life easier for the programmer writing code for a one-off task.


We can try like,



var incnum = 'INC0010240,INC0010234,INC0010233,INC0010200,INC0010214,INC0010211,INC0010209,INC0010208,INC0010207,INC0010206,INC0010204,INC0010203,INC0010202,INC0010201';


var incnumarray = incnum.split(',');


var abc= new GlideRecord('incident');


for(var i = 0; i < incnumarray.length; i++){


if(abc.get('number', incnumarray[i].trim()))


gs.print(abc.active);


}