- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 07:38 AM
I have to create a problem record when Incident state is resolved and priority is '1-Critical'. I have tried it using business rule but i am getting an error.
The Error is:- Unique Key violation detected by database (Duplicate entry '778bdfe6db4122005a91d421cf96193c' for key 'PRIMARY')
My business rule scripts is:-
When to run:- State is resolved AND prioirity is 1-critical AND problem_id is empty.
Script :-
(function executeRule(current, previous /*null when async*/) {
var prob = new GlideRecord("problem");
prob.short_description = current.short_description;
prob.cmdb_ci = current.cmdb_ci;
prob.priority = current.priority;
//gs.addInfoMessage(prob.work_notes);
//gs.addInfoMessage(answer);
var sysID = prob.insert();
current.problem_id = sysID;
var mySysID = current.update();
gs.addInfoMessage("Problem " + prob.number + " created");
action.setRedirectURL(prob);
action.setReturnURL(current);
})(current, previous);
After testing a problem record is created but still above error is coming. what is this error and how to correct it???
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 07:42 AM
Hi Anubhav,
Can you turn off this BR and check once. If the issue still exists then there must be current.update() line in BEFORE Business rule on the table.
Please check for the same on your instance once.
http://wiki.servicenow.com/index.php?title=Business_Rules_Best_Practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2016 05:30 PM
Hi Chuck,
I am looking something like:
I have an existing record in a table, I want to insert the same record entry in another table if some condition matches.
Can I do it using the sys_id of that entry? Can you please share some code?
Thanks
Jyo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2016 12:11 AM
Hi Jyoti,
I have done similar kind of requirement but using button called 'Copy Incident' to copy some field values in new record. I dont think we can do it using directly by sys_id. U can try business rule for your requirment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 07:42 AM
Hi Anubhav,
Can you turn off this BR and check once. If the issue still exists then there must be current.update() line in BEFORE Business rule on the table.
Please check for the same on your instance once.
http://wiki.servicenow.com/index.php?title=Business_Rules_Best_Practices

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2016 07:42 AM
Run this in After Business rule and use prob.initialize();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2023 11:10 PM
Hi
How to configure without business rule, To create problem record when incident is resolved and priority is P1 and P2 in DOP Instance.