- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 12:13 AM
Hi,
I found something interesting. Even I was unable to change the active field in my case. I debugged there is 1 query business rule that might be causing the issue so I used setWorkflow(false) before query and it updated the flag
update your code as below and try once:
var yearAgo = gs.daysAgo(365);
var gr = new GlideRecord("sys_template");
gr.addQuery('u_pre_approved', true);
gr.addQuery("u_approving_rfc.cab_date", "<", yearAgo);
gr.setWorkflow(false);
gr.query();
gs.print('** DEBUG ** ROWCOUNT :'+gr.getRowCount());
while(gr.next()) {
gs.print('** DEACTIVATING ** '+gr.name);
gr.active=false;
gr.update();
}
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader