fix script

shid077
Tera Contributor

i have to write a fix script for closure for old transactional records which are active true for more than 6 months for Incident and change table.

 

what will be my fix script.

 

can anyone please provide me the code or fix script for this.

 

 

 

3 REPLIES 3

Weird
Mega Sage

Hi, I recommend checking guides and now learning courses for scripting in Servicenow.
This is relatively simple to do, but you'd want to understand the code before you run it as someone might accidentally give you a code that, for example, incorrectly updates records.

As a hint check GlideRecord queries and updating and see how to use query builder condition with gliderecord.

Ankur Bawiskar
Tera Patron
Tera Patron

@shid077 

this should be an easy one.

what did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi @shid077 ,

Can you please check this script below 

var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^sys_created_on<javascript&colon;gs.beginningOfLast6Months()');
gr.query();
gs.print('Count = ' + gr.getRowCount())
while(gr.next()){
	//your code here
}

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak