to avoid creation of duplicate problem records
Options
- 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:
(function executeRule(current, previous /*null when async*/ ) {
var prob = new GlideRecord("problem");
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);
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2025 12:17 AM
Hi @sureshp89882164 ,
if it is a After Update BR use this
if it is a Before Update BR comment the current.setWorkflow(false) and current.update()
(function executeRule(current, previous /*null when async*/ ) {
var prob = new GlideRecord("problem");
prob.addEncodedQuery('first_reported_by_task=' + current.getValue('sys_id'));
prob.query();
if (!prob.hasNext()) {
prob.initialize();
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;
current.problem_id = prob.insert();
current.setWorkflow(false); //comment this if the make if it's a before update BR
current.update(); //comment this if the make if it's a before update BR
gs.addInfoMessage("Problem " + prob.number + " has been created.");
}
})(current, previous);