updating incident by change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 02:46 AM
We have a ui action which automatically adjusts the status of a related incident when a problem is opened. The status of the incident then changes to “on hold” > “awaiting problem”
Now we would like to have the same for the change request. If a change request is opened from an incident, the incident should change to “on hold” > “awaiting change”.
We also have a business rule which sets the incident to “resolved” with the text from the solution to the problem.
For the change, we want the incident to change to “in progress” as soon as the change has been implemented so that our 1st level support knows that the affected user can be informed.
How can we achieve this?
i have tried to use the existing business rule as a template and changed the table from “problem” to “change request”, but as hard as i try to adapt the scripts accordingly, i do not get the desired result. at the moment the incidents which are located under “related records” > “incidents fixed by change” are not updated.
so it is currently available & works:
UI Action: create problem
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);
}
UI Action: create change Request:
function onClick(g_form) {
getMessages(['Create Change Request', 'Create', 'Cancel'], openInterceptorModal);
function openInterceptorModal(msg) {
var result = g_form.submit('create_std_change');
if (!result) {
return;
}
result.then(function() {
g_modal.sn_itsm_workspace.showInterceptor({
title: msg['Create Change Request'],
confirmTitle: msg['Create'],
cancelTitle: msg['Cancel'],
size:'sm',
height:'md',
params: {"modal": "false","target":"change_request"}})
.then(function(modalResult){
if (modalResult.data) {
if (modalResult.data.table != 'sc_cat_item')
g_aw.openRecord(modalResult.data.table, modalResult.data.sys_id, {query:modalResult.data.query});
else {
var ga = new GlideAjax('StdChangeUtils');
ga.addParam('sysparm_name', 'ajaxFunction_getCategory');
ga.getXMLAnswer(function (answer) {
if (answer) {
var params =modalResult.data.params;
params.sysparm_parent_table = "incident";
params.sysparm_parent_sys_id = g_form.getUniqueValue();
g_service_catalog.openCatalogItem('sc_cat_item', '-1', params);
}
});
}
}
});
});
}
}
Business Rule: close related
if (current.problem_state.changesTo(4)) {
closeRelatedIncidents(current);
closeRelatedTasks(current);
}
//
// Close any incidents that are related to the current problem
//
function closeRelatedIncidents(me) {
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", me.sys_id);
incident.query();
while (incident.next()) {
if ( incident.active == true ){
var msg = gs.getMessage("Incident {0} closed based on closure of problem {1}", [incident.number, me.number]);
gs.print(msg);
incident.incident_state.setValue(IncidentState.CLOSED);
incident.active.setValue(false);
incident.comments = msg;
incident.update();
}
}
}
Thanks in advance for your input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 03:45 AM
1. You can make use "Change Request" field on incident form under Related records tab (OOB available)
2. Now , ideally as per my knowledge, when Change request is created/updated, change requester/Implementer should add manually by using edit button in the related list -"Incidents fixed by this changes"- - affected incidents.
3. Once it's done, you should have Change Request field on incident is updated.
4. Now you can write Display Business rule on incident table with script as follows.
in condition add - Change Request is not empty and active true
in script- if (current.rfc.state == " Put Implement state Value"){ // Note rfc backend name for Change Request field.
current.state= "Put Work in Progress value"
current.update();
}
Hope it helps.
Please mark my response as helpful/correct if it helps.
Regards,
Priyanka Salunke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 04:12 AM
What happens in your process when a problem is created from an incident and then that problem is going to be solved by a change? Or a change causing an incident, going to be a problem, etc?
If that is of no consideration, leave the BR what it is and go for a flow. When you create a change from an incident, let the flow start and you can just simply do everything in there. You have access to all data of the change and all data of the incident.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2024 04:13 AM
I think there is a misunderstanding
If I create the change by selecting “related records” > “change request” > “new” in the Incident, then this change is a child of the Incident.
This change then has no incident as a child in its “related records”:
In my opinion, this is wrong because the change in our case is created from the incident via UI action in workspace:
And if it is done this way, then the change also has a related incident which would be fixed by implementing the change.
Of course, you can manually add the incidents to a change that are to be resolved by the change, but we can also cover this by adding all other incidents that are dependent on this change to the existing incident as “children”. The incident from which the change was created then acts as the parent and when this parent is updated or closed, the related incidents inherit the status. this solution is available and works.
kind regards