Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To close a parent record when its children are closed in ServiceNow, create a Business Rule or Flow Designer on the child table. This rule should trigger when a child record's state changes to "closed," check if all related child records are closed, and then update the parent record's state accordingly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but that script is full of issues and makes no sense at all. I don't know where to start and in the end I cannot rewrite everything for you.

However, at least one important hint. The code line "child.parent_incident.update()" will not work. If you want to update the parent record you have to load an individual instance, for example with "getRefRecord()"
For more information please refer https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0745222

And also "hello" loggings do not provide any value and spam the syslog table!

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var pSysId = 'sys_id';
var child= new GlideRecord('incident');
child.addQuery('parent_incident',pSysId);
child.query();
var count=0;
while(child.next()){

if(child.state!=7)
{
count =1;
gs.print("your child incident is not there or is not yet closed");
}
}
if(count==0){
child.parent_incident.state=7;
child.parent_incident.close_code='Duplicate';
child.parent_incident.close_notes="done";
child.parent_incident.update();
gs.print("hello" + child.parent_incident.number);
}
Loading