A non-unique index exists on this column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 12:35 AM - edited 04-15-2024 12:42 AM
When I try to mark a column on parent table as Unique. IT throws below error . Deleted unique fields on Childs and updated data in column to make sure its unique. Tried setting index as true too
A non-unique index exists on this column. To create a unique index for this column use IndexCreator in the Tables & Columns page or in this column's Table record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 12:56 AM
@Kumar38 , can you add the screenshot and at least the table it is about (and if it extends something, the parent, like task)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 01:01 AM - edited 04-15-2024 01:05 AM
The parent and child all are custom tables. Parent doesn’t extend any table. Field is string field used for auto numering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 12:15 AM
Have a look at https://www.servicenow.com/community/platform-analytics-articles/get-duplicate-records-from-any-tabl.... This way you can get the existing duplicates out of the system.
If the index is not being created, because it says non-unique, there must be a duplicate somewhere.
As background script, delivering something like :
*** Script: INC0008111,INC0009009
gs.info(getDuplicates('incident','number')); //your table and fieldname
function getDuplicates(table, field) {
var dupRecords = [];
var gaDupCheck = new GlideAggregate(table);
gaDupCheck.addAggregate('COUNT', field);
gaDupCheck.addNotNullQuery(field);
gaDupCheck.groupBy(field);
gaDupCheck.addHaving('COUNT', '>', 1);
gaDupCheck.query();
while (gaDupCheck.next()) {
dupRecords.push(gaDupCheck[field].toString());
}
return dupRecords;
}