- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2019 12:13 PM
Hi Community,
I would like to create a script that will query any records where resolved_at and resolved_by are empty, and set them to a specific value.
I had assistance creating the following script to update records on my user table.
How do I alter the script to work on the incident table?
var recUser = new GlideRecord('sys_user');
recUser.addEncodedQuery('company=a828cffe993928006d095f1cc569621f^sys_class_name!=sys_user^ORsys_class_name=NULL');
recUser.query();
gs.info(recUser.getRowCount());
while(recUser.next()){
recUser.sys_class_name = 'sys_user';
recUser.update();
}
Thanks,
Heather
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2019 05:44 AM
You want the resolved_at to be 24 hours after the incident was closed? Wouldn't that be a bit weird? To have the ticket resolved after it was closed?
You can do it this way but check out how to do it 24 hours before as well:
//to set resolved after closed:
var gdt = new GlideDateTime(recUser.getValue('closed_at'));
gdt.addDays(1);
recUser.resolved_at = gdt;
recUser.resolved_by = ''; // Pass the sys_id of the user
recUser.update();
//to set resolved before closed:
var gdt = new GlideDateTime(recUser.getValue('closed_at'));
gdt.addDays(-1);
recUser.resolved_at = gdt;
recUser.resolved_by = ''; // Pass the sys_id of the user
recUser.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2019 05:16 AM
Thanks David!