Need to set the Number field Unique and delete all duplicate records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 02:54 AM
Hi All,
I want to set the Number field for Incident as Unique, But when I am trying to set it as Unique, its showing an error as "New Unique index skipped: Requested columns (number) on table (task) contain duplicate values. You must remove duplicate values and then try again."
Can anyone let me know how to fix this issue. I want to delete all duplicate Incident Records but I am not finding any possibilities or tricks to fix this.
Thanks,
SNOW@Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 03:57 AM
You can run a background script and delete the duplicates -
https://community.servicenow.com/community?id=community_question&sys_id=fa709ee3dbec9fc87b337a9e0f961991
var gr = new GlideRecord('u_incident');
gr.groupBy('number');
gr.query();
while(gr.next()){
var inc = new GlideRecord('u_incident');
inc.addQuery('number', gr.number);
inc.query();
inc.next();
while(inc.next()){
inc.deleteRecord();
}
}