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

Automated script

eashwar
Tera Contributor

is there any scripts which can be used to run after patches.

Scripts to create/close new incident, change and problem ?

6 REPLIES 6

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

HI Eashwar,



Can you please elaborate your question further.


If you want to mass update the bulk records then you can prepare a fix script and run it through Background script or as part of fix script.



Please let me know if you have any questions.


Hi Pradeep,


Basically I wanted to write some test scripts which can,


1. Create and Close test incident/Problem/Change


Instead of manually creating one.




This way I can run it to test ITIL functionality after patching.




Thank you,


Eashwar Elumalai


Yes, you obviously can very easily script something that will do this. Are you just asking us to do it for you?


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Eashwar,



You could use javascript to create update and delete records and run these via Background Scripts:


along the lines of:


Using GlideRecord to Query Tables - ServiceNow Wiki


..


3.2 update



var rec = new GlideRecord('incident');


rec.addQuery('active',true);


rec.query();


while (rec.next()) {


  rec.active = false;


  gs.print('Active incident ' + rec.number = ' closed');


  rec.update();


}



3.3 insert


var rec = new GlideRecord('incident');


rec.initialize();


rec.short_description = 'Network problem';


rec.caller_id.setDisplayValue('Joe Employee');


rec.insert();



3.4 delete


var rec = new GlideRecord('incident');


rec.addQuery('active',false);


rec.query();


while (rec.next()) {


  gs.print('Inactive incident ' + rec.number + ' deleted');


  rec.deleteRecord();


}



Or you could consider automated testing via the GUI.


There are quite a lot of free tools available to test web applications.



Perhaps some Community members have done something similar, and might share their experiences.



Best Regards



Tony