A non-unique index exists on this column.

Kumar38
Kilo Sage

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

3 REPLIES 3

Hayo Lubbers
Kilo Sage

@Kumar38 , can you add the screenshot and at least the table it is about (and if it extends something, the parent, like task)?

 

The parent and child all are custom tables. Parent doesn’t extend any table. Field is string field used for auto numering

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;
}