Create Problem UI Action Issue

purdue
Kilo Sage

Hello,

We are running into an issue with a business rule is running but not stopping processing of a ui action.   

When using the create a problem ui action the problem record is created and linked to the incident, however due to the br running which requires the user to attach impacted countries through related list the form is refreshed and the related problem is no linked to the incident leaving a orphaned problem record.  Any suggestions are welcome and appreciated.   

The before business rule runs when inc category is Broadcast Transmission and assigned group is BCC and state changes.  The advanced condition is 

var gr = new GlideRecord("u_m2m_core_country_incident");
gr.addQuery("u_incident", current.sys_id);
gr.query();
if (!gr.next()) {
gs.addErrorMessage("Please attach all impacted countries to the incident form before updating the incident state");
current.setAbortAction(true);
}
Here is the Incident UI Action.
 
var item = current.cmdb_ci;
if (JSUtil.notNil(item)) {
var prob = new IncidentUtils().getProblemFromIncident(current);
if (prob != undefined) {
current.problem_id = prob.insert();
if (current.state != IncidentState.RESOLVED) {
current.state = IncidentState.ON_HOLD;
if (current.isValidField("hold_reason"))
current.hold_reason = IncidentState.AWAITING_PROBLEM;
}
if (GlidePluginManager.isActive("com.snc.best_practice.problem.madrid")) {
var problemV2Util = new ProblemV2Util();
problemV2Util.copyAttachments(current, prob);
problemV2Util.copyAttachedKnowledge(current, prob);
}
current.update();
gs.addInfoMessage(gs.getMessage("Problem {0} created", prob.number));
action.setRedirectURL(prob);
action.setReturnURL(current);
} else {
action.setRedirectURL(current);
}
} else {
action.setRedirectURL(current);
gs.addErrorMessage('CI field is required before creating a problem record');
}
1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

I think the solution would be to add this script to the UI action too, so that impacted countries are associated before a problem record is associated.

var gr = new GlideRecord("u_m2m_core_country_incident");
gr.addQuery("u_incident", current.sys_id);
gr.query();
if (!gr.next()) {
gs.addErrorMessage("Please attach all impacted countries to the incident form before updating the incident state");
}
else
{
var item = current.cmdb_ci;
if (JSUtil.notNil(item)) {
var prob = new IncidentUtils().getProblemFromIncident(current);
if (prob != undefined) {
current.problem_id = prob.insert();
if (current.state != IncidentState.RESOLVED) {
current.state = IncidentState.ON_HOLD;
if (current.isValidField("hold_reason"))
current.hold_reason = IncidentState.AWAITING_PROBLEM;
}
if (GlidePluginManager.isActive("com.snc.best_practice.problem.madrid")) {
var problemV2Util = new ProblemV2Util();
problemV2Util.copyAttachments(current, prob);
problemV2Util.copyAttachedKnowledge(current, prob);
}
current.update();
gs.addInfoMessage(gs.getMessage("Problem {0} created", prob.number));
action.setRedirectURL(prob);
action.setReturnURL(current);
} else {
action.setRedirectURL(current);
}
} else {
action.setRedirectURL(current);
gs.addErrorMessage('CI field is required before creating a problem record');
}

Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

7 REPLIES 7

Hello,

The issue is the problem record is created and associated with the incident but then is lost due to filling out the impacted countries.

Thanks,

Chad

"but then is lost due to filling out the impacted countries." - How is this done? By the user? Is this custom related table linked to the incident or the problem.

Hello,

I attached screenshots.   So when creating a problem from incident the br requires that the countries be attached and then the user clicks edit and adds a country and thats when the problem that was created is now gone.   Thanks, Chad