- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2022 10:32 PM - edited 10-04-2022 10:37 PM
Hi,
Can anyone please help us on the below requirement.
We want to close all the child INC tickets when the Parent INC ticket state changes to closed.
We wrote one After / update --> Business rule but some reasons the child ticket state not changing to closed.
and also we want to copy the work notes and parent inc number from parent to child ticket work notes.
Script:
(function executeRule(current, previous /*null when async*/) {
var num = current.number;
var inc = new GlideRecord('incident');
inc.addActiveQuery();
inc.addQuery('parent',current.sys_id);
//inc.orderByDesc('sys_created_on');
inc.query();
while(inc.next())
{
if(inc.incident_state != 7)
{
inc.incident_state = 7;
if(JSUtil.notNill(current.comments.getJournalEntry(1)))
{
inc.comments = num + " : " + current.comments.getJournalEntry(1);
}
inc.update();
}
}
Advance Thanks.
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 03:00 AM - edited 10-05-2022 03:01 AM
Hello,
The attached notepad contains the filter condition and the complete script just copy paste it:-
Please mark my answer as correct.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 10:55 PM - edited 10-05-2022 11:04 PM
Hi Saurav,
One doubt,
i have attached the script, in that there is a function called "updateChildren" used for resolved logic.
Do you want us to use the same for closed logic as well.
Script:
function updateChildren(fields) {
if (fields.length < 1)
return;
var rec = new GlideRecord("incident");
rec.addQuery("parent_incident", current.sys_id);
rec.addQuery("state", "!=", IncidentState.RESOLVED);
rec.addActiveQuery();
rec.query();
while (rec.next()) {
for (var i = 0; i < fields.length; i++) {
rec[fields[i].name] = fields[i].value;
}
rec.update();
}
}
Advance thanks for the support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 11:01 PM
Hello,
No i think you can exclude that for closed logic as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 11:25 PM
Thank you so much.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2022 03:36 AM - edited 10-10-2022 03:37 AM
Hi Saurav,
Sorry for disturbing you.
One small doubt,
In the below script (red line) some time the output coming very strange:
Notes are coping from parent to child incident ticket.
but it's coming like this ---> some time "NaN" or "0" also we're seeing in child INC ticket resolution notes.
"NaN copied from Parent Incident:
Test cascade closure / as Resolution"
Advance thanks.
if (incident.isValidField("close_notes") && incident.close_notes.nil()) {
msg = gs.getMessage('{0} copied from Parent Incident', current.close_notes.getLabel());
if (current.close_notes.toString().indexOf(msg) == 0)
incident.close_notes = current.close_notes;
else
incident.close_notes = msg + ": " + \n + current.close_notes;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2022 03:54 AM
Yeah you can hardcore the lines and do not have to keep 0, so no matter what you will not receive any such message as NaN