Unique Key violation detected by database ((conn=999850) Duplicate entry '781b08101b739450c91421b4bd4bcb90' for key 'PRIMARY')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 05:45 AM
We have a Business Rule that creates an Incident from a New Call. When it runs, it gives the following error message, but continue to create the incident as expected:
"Unique Key violation detected by database ((conn=999850) Duplicate entry '781b08101b739450c91421b4bd4bcb90' for key 'PRIMARY')"
I found many pointers from this Community advising against the use of "current.update()" on Business Rules. I then commented this part out of my script, but I still get the same error.
Could you please advise what else could be causing this error.
Background info: This Buiness Rule was converted from a UI Action where everything was working fine, but the same script gives the error on a Business Rule.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2020 07:05 AM
Hi Asifnoor,
I tried with your code, to no success - still getting the same error message.
Kind Regards
Arnold
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 03:06 AM
Not sure, you can try change your BR to: before-insert (new_call).
Otherwise, I think you can provide more information of this BR.
==> I think this is loop-execution issue ==> 1 incident generated 2 times (duplicated sysid)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 03:43 AM
Is this Br written on call update also?
Can yo ucheck if insert and update both are checked. Remove update and test once becuase in your Br you are updating the call details.
Also is it before or after BR?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 03:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2020 04:02 AM
Hi Remove insert then.
And secondly check if there is any other BRs running on this table which is also creating an incident?
For debugging purpose, just keep this code and test once and see if you still get 2 incidents?
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var inc = new GlideRecord("incident");
inc.initialize();
inc.parent = current.sys_id;
inc.caller_id = current.u_requested_for;
inc.assignment_group = current.assignment_group;
inc.impact = 4;
inc.urgency = 4;
inc.contact_type = current.contact_type;
inc.opened_by = gs.getUserID();
inc.location = current.location;
inc.short_description = current.short_description;
inc.description = current.description;
var sysID = inc.insert();
/*
inc.get(sysID);
//Set the New Call Record
current.parent = sysID;
current.active = false;
current.state = 1;
current.close_notes = 'Transferred to Incident';
current.u_call_type = 'Incident';
//English or Null
if ((current.requested_for.preferred_language == 'en') || (current.requested_for.language == ''))
current.comments = "An incident was logged with INCIDENT NO: " + inc.number;
if ((inc.opened_by.preferred_language == 'en') || (inc.opened_by.preferred_language == ''))
gs.addInfoMessage("Incident " + inc.number + " created");
//Brazilian Portuguese
if (current.requested_for.preferred_language == 'pb')
current.comments = "O Incidente foi criado com o número: " + inc.number;
if (inc.opened_by.preferred_language == 'pb')
gs.addInfoMessage("Incidente " + inc.number + " criado");
//Spanish
if (current.requested_for.preferred_language == 'es')
current.comments = "Un incidente ha sido logueado con Nro de Incidente: " + inc.number;
if (inc.opened_by.preferred_language == 'es')
gs.addInfoMessage("Incidente " + inc.number + " creado");
GlideSysAttachment.copy('new_call', current.sys_id, 'incident', sysID);
//var mySysID = current.update();
gs.setRedirectURL(inc); // Redirect to an incident record
gs.setReturnURL(current); //return to the New Call record
*/
})(current, previous);