Script Needed
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 08:32 AM
HI All,
I need a script to update the incident table
Requirement:
I need to capture the updated time and add it in closed field
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2024 08:44 AM
Hi,
Try something like this in a fix script.
Please test once with one record before running it for bulk.Try in lower instance before running it on prod
updateINC();
function updateINC(){
try{
var gr = new GlideRecord('incident');
gr.addEncodedQuery("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); //Add records or filter you want to update
gr.query();
var count = 0;
while(gr.next()){
count++;
gr.closed_at=gr.sys_updated_on;
gr.setWorkflow(false);
gr.setUseEngines(false); // to prevent data policy from blocking the update
gr.update();
}
gs.info('Total INC updated' + count);
}
catch(ex){
gs.info('exception' + ex);
}
}
-Anurag