Duplicate Entry....Invalid Insert - How to troubleshoot and identify cause?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2015 12:09 AM
I can create the Domain tree as needed but I am getting the error below when I try to Insert the 'ACME' domain
Unique Key violation detected by database (Duplicate entry 'Acme' for key 'domain_u')
Invalid insert
I have checked the error logs and found these:
Warning Cancelling transaction #7714 /sys_db_object_list.do (cancelled by other transaction): Thread Default-thread-3 (stephen.gannon, 3F4EE1FF6FA0020093ACAA385E3EE441), after 13237ms Transaction |
and this;
Error FAILED TRYING TO EXECUTE ON CONNECTION 17: INSERT INTO domain (`sys_updated_on`, `sys_id`, `parent`, `sys_created_on`, `type`, `sys_created_by`, `default`, `sys_domain_path`, `sys_domain`, `sys_updated_by`, `name`, `primary`, `active`, `sys_domain_code`, `sys_mod_count`) VALUES('2015-06-16 13:46:24', '6bafa1336fe0020093acaa385e3ee455', '11b914080f943100308a0eece1050ecc', '2015-06-16 13:46:24', 'Customer', 'stephen.gannon', 0, '!!!/!!$/!!!/!!#/', '6bafa1336fe0020093acaa385e3ee455', 'stephen.gannon', 'Acme', 0, 1, '!!#', 0)
Unique Key violation detected by database (Duplicate entry 'Acme' for key 'domain_u')
I can't find the domain_u anywhere, or any Acme listed in the GUI and I can't see how to use the sysid for the referenced pre-existing Acme domain entry.
I have checked the Business Rules related to the Domain form, but no clues there either?
Any pointers on how to troubleshoot would be greatly appreciated.
Regards
Steve

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2015 12:20 AM
Hi Stephen,
Check if there is any BR which has current.update() in before business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2015 12:32 AM
Hi Stephen, the key violation appears to be occurring on your name field. Would you mind sharing how you're creating this domain tree?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2015 12:58 AM
Hi Berny, Pradeep,
Below are two business rules on the Domain table with the primary or primaryDomain.update(); but not current.update()
I have been adding domains to an existing Domain tree, with Acme being the first one to insert. I add the new domains via the Domain list veiw and the NEW button. I have added a few others with no issue.
It is a MSP/Domain enabled instance, and I suspect Acme may have been created/deleted and some artifact remains causing the conflict? But I can't see anything in the logs.
Thanks
Steve
Domain - Validate Default
before
Condition = current['default'].changesTo(true)
GlideProperties.removeProperty("glide.domain.default");
validateDefaultDomain();
function validateDefaultDomain() {
var defaultDomain = new GlideRecord('domain');
defaultDomain.addQuery('default', 'true');
defaultDomain.addQuery('sys_id', '!=', current.sys_id);
defaultDomain.queryNoDomain();
if (!defaultDomain.hasNext())
return;
gs.addInfoMessage(gs.getMessage('Only one Domain may be set as Default'));
var checkIt = new GlideRecord('domain');
if (!checkIt.get(defaultDomain.sys_id)) {
gs.addInfoMessage("A domain you cannot see is already Default - canceling update");
current.setAbortAction(true);
return;
}
gs.addInfoMessage(gs.getMessage('"Default" field automatically unchecked for Domain') + ': <b>' + defaultDomain.name + '</b>');
defaultDomain.setValue('default', false);
defaultDomain.update();
}
AND
Domain - Validate Default
before
Condition = current.primary.changesTo(true) || current.primary.changesFrom(true)
GlideProperties.removeProperty("glide.domain.primary");
validatePrimaryDomain();
function validatePrimaryDomain() {
var primaryDomain = new GlideRecord('domain');
primaryDomain.addQuery('primary', 'true');
primaryDomain.addQuery('sys_id', '!=', current.sys_id);
primaryDomain.queryNoDomain();
if (!primaryDomain.next())
return;
gs.addInfoMessage(gs.getMessage('Only one Domain may be set as Primary'));
var checkIt = new GlideRecord('domain');
if (!checkIt.get(primaryDomain.sys_id)) {
gs.addInfoMessage("A domain you cannot see is already Primary - canceling update");
current.setAbortAction(true);
return;
}
gs.addInfoMessage(gs.getMessage('"Primary" field automatically unchecked for Domain') + ': <b>' + primaryDomain.name + '</b>');
primaryDomain.setValue('primary', false);
primaryDomain.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2015 01:13 AM
Hi Stephen, I don't see any insert() on the code you shared. Would it be possible the insert() is actually somewhere else?
Thanks,
Berny