Fix script for update the assignment group to original assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2024 01:24 AM
Hi All,
Fix script for update the assignment group to original assignment group.
I have created new field as original assignement group and created a BR for update the assignment group details to the original assignment group.
data updating fine after creating the BR for new sctasks.
I want to update the old task as well , can anyone please help for the fix script to update the assignment group to the original assignment group.
I want to update the first assignment group what ever when ticket is created.
var sctask = new GlideRecord('sc_task');
sctask.setLimit(100);
sctask.query();
while (sctask.next()) {
var originalGroup = sctask.getValue('assignment_group');
if (originalGroup) {
sctask.setValue('u_original_assignment_group', originalGroup);
sctask.setWorkflow(false); // Prevents running business rules and workflows
sctask.update();
gs.log('Task ' + sctask.number + ' successfully updated to original assignment group.');
} else {
gs.log('Original assignment group not found for task ' + sctask.number);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2024 07:23 AM
add one more setvalue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2024 07:36 AM
Hi Barathk,
You need to check your "metric_instance" table for historical data.
run your logic on it and update task data.
Thanks,
Sanjeev Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2024 09:30 AM
Hi @Barathk ,
You can use sys_audit table to get old value. But this table is very big in the number of rows and might affect the performance of the system.
check the replies and you will find the code in this question.
You can use that as reference and can modify as per your requriement.
Mark the comment as a correct answer and also helpful if it helps.
Thanks & Regards,
Sumanth Meda