Duplicate problem records being created

Shalika
Tera Expert

I have a business rule written that whenever a P1/P2 incident is resolved then a problem ticket will be created automatically. The problem ticket is being generated correctly, but there are some cases 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?

 

(function executeRule(current, previous /*null when async*/) {

var prob = new GlideRecord("problem");

prob.short_description = current.short_description;
prob.u_business_service = current.u_business_service;
prob.cmdb_ci = current.cmdb_ci;
prob.priority = current.priority;
prob.description = current.description;
prob.opened_by = current.opened_by;
prob.assignment_group = "712cc9bb0ff28600b11cf68ce1050ec1";
prob.state = 2;
prob.parent = current.sys_id;
prob.sys_domain = current.sys_domain;

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);

1 ACCEPTED SOLUTION

suvro
Mega Sage
Mega Sage

Just execute your code inside the if {} in below code

 

if (current.problem != ""){

Your code here

}

View solution in original post

3 REPLIES 3

Jaspal Singh
Mega Patron
Mega Patron

Configure hte Business rule to run After instead of Before.

Also, only Update would suffice your need no need of Insert.

@Shalika I see you marked both the answer correct but there can be only one correct per thread. Suggest you to mark the one that helped & understand the cause.

suvro
Mega Sage
Mega Sage

Just execute your code inside the if {} in below code

 

if (current.problem != ""){

Your code here

}