to avoid creation of duplicate problem records
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 11:58 PM
I have a business rule written that whenever a P1/P2 incident is resolved then a problem record will be created automatically. The problem record is being generated correctly, but there are some times where duplicate problem records are being created with different problem numbers.
What condition should I put in my BR to avoid creation of duplicate problem records?
Business Rule is below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2025 12:03 AM - edited ‎05-20-2025 12:10 AM
I hope you configured BR with the correct condition such as below and it's after update
State [Changes To] Resolved
is the INC getting resolved multiple times? if yes then it will create multiple Problems
in the business rule script add this to see if already PRB is present for the INC which is getting Resolved
I could see you are using this "first_reported_by_task" field on PRB to store INC, I just used the same to query
(function executeRule(current, previous /*null when async*/ ) {
var prob = new GlideRecord("problem");
prob.addQuery('first_reported_by_task', current.sys_id);
prob.query();
if (!prob.hasNext()) {
prob.first_reported_by_task = current.sys_id;
prob.short_description = current.short_description;
prob.description = current.description;
prob.cmdb_ci = current.cmdb_ci;
prob.impact = current.impact;
prob.urgency = current.urgency;
prob.u_category = current.category;
prob.business_service = current.business_service;
if (current.major_incident_state == "accepted" && (current.priority == 1 || current.priority == 2)) {
prob.major_problem = true;
prob.assignment_group = gs.getProperty('command.centre.incident.communications');
} else {
prob.major_problem = false;
prob.assignment_group = current.assignment_group;
}
prob.u_caused_by_change = current.caused_by;
prob.priority = current.priority;
prob.company = current.company;
prob.sys_domain = current.sys_domain;
prob.insert();
var sysID = prob.sys_id;
current.problem_id = sysID;
current.setWorkflow(false);
current.update();
current.setWorkflow(true);
gs.addInfoMessage("Problem " + prob.number + " has been created.");
}
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2025 08:20 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2025 12:07 AM
Hi @sureshp89882164 ,
1. Add a condition to check if current.problem_id is empty or not. If empty only do the following logic.
1. You shouldn't use current.update() in Business Rule. To omit the current.update(), try to use before update BR.
Please mark answer correct/helpful based on impact
Thanks
Deborah Brown
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2025 12:07 AM
Hi @sureshp89882164 ,
Please check
Adding a unique constraint on the combination of first_reported_by_task in the problem table (if business logic allows).
Making sure the BR has a proper condition, such as:
current.state == 6 && // Resolved previous.state != 6 && (current.priority == 1 || current.priority == 2) && current.problem_id.nil()