"Unique Key violation detected by database " - Error Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2022 05:55 AM
Hi All,
I have created new BR to add all Parent CIs into "Affected CI" Related list based on CI we have selected on configuration item field.
I got the error message when I am updating the CI on change record. I have checked some community posts that it is because of "current.update()" used in BR. I have checked that as well, we are not using it in BR. Can anyone please help me what could be the cause of this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2022 06:40 AM
Can you post the script of your new Business Rule please?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2022 07:37 AM
Hi,
I have written below script.
BR:
(function executeRule(current, previous /*null when async*/) {
var uniqueOutageSysIDs;
if (getTableExtensions('cmdb_ci_server').indexOf(current.cmdb_ci.sys_class_name) != -1) // CI class is a Server.
{
uniqueOutageSysIDs = new PopulateAffectedCI().ServerCI(current);
}
gs.addInfoMessage('Affected CIs are attched to the Affected CIs tab');
})(current, previous);
Script Include:
ServerCI: function(chg)
{
var ci_app_to_server_gr = new GlideRecord('cmdb_rel_ci');
ci_app_to_server_gr.addEncodedQuery('child=' + chg.cmdb_ci);
ci_app_to_server_gr.query();
while (ci_app_to_server_gr.next())
{
var ser = new GlideRecord('task_ci');
ser.initialize();
ser.task = chg.sys_id;
ser.ci_item = ci_app_to_server_gr.parent; // Inserting all parent CIs
ser.xml = "<auto_generated>true</auto_generated>";
ser.insert();
}
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2022 07:04 AM
Hi @MS17 ,
could you please share the business rule script?
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2022 07:19 AM
Hi @MS17 ,
refer below link it is one of the scenarios. May be other Business rule which is causing this conflict.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0751326
ServiceNow Community MVP 2024.
Thanks,
Pavankumar