Update Child with Parent 'Assigned To' I know it's been covered but please read.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2013 06:06 AM
We have a business rule that closes incidents when a parent incident is closed however I would like the Assigned To field to be populated in the child record once the parent incident status changes to 8, currently it is not populated. The BR is very simple:-
Run on the Incident table at server and after. Insert and Update are ticked.
Condition is - current.isValidRecord()
Script is - //
// Close any child incidents
//
if (current.active.changesTo(false)) {
closeRelatedTasks(current);
}
I have played around with many changes but cannot get it to work, does anyone have a suggestion for me as none of the suggestions posted here appear to work either.
The parent field on our incident record is a reference field back to task.
TIA
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2013 02:36 AM
I changed part of the BR that was global from:-
function NYKcloseIncident(myID, fromTask) {
var incident = new GlideRecord('incident');
if (incident.get('sys_id', myID)) {
var msg = "Incident " + incident.number + ' closed based on closure of task '+ fromTask.number;
gs.print(msg);
setIncidentState(incident, fromTask);
incident.active.setValue(false);
incident.comments = msg;
incident.close_notes = fromTask.close_notes;
incident.update();
}
}
TO:-
function NYKcloseIncident(myID, fromTask) {
var incident = new GlideRecord('incident');
if (incident.get('sys_id', myID)) {
var msg = "Incident " + incident.number + ' closed based on closure of task '+ fromTask.number;
gs.print(msg);
setIncidentState(incident, fromTask);
incident.active.setValue(false);
incident.comments = msg;
incident.assigned_to = fromTask.assigned_to;
incident.assignment_group = fromTask.assignment_group
incident.close_notes = fromTask.close_notes;
incident.update();
}
}
And it now works, thanks for all your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2015 11:48 AM
Hi Angus,
I am very new to Servicenow, just want to check, how do we call this function. What are the values we need to pass to the function for myID and fromTask.