fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 11:33 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 11:45 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2024 11:54 PM
this should be an easy one.
what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 12:02 AM
Hi @shid077 ,
Can you please check this script below
var gr = new GlideRecord('incident');
gr.addEncodedQuery('active=true^sys_created_on<javascript: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