From ebf13530d291ccb78c8fa273595f05ccde07a751 Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:08:36 +0530 Subject: [PATCH 1/2] Create readme.md --- .../Business Rules/Update Incident State To Closed/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 Server-Side Components/Business Rules/Update Incident State To Closed/readme.md diff --git a/Server-Side Components/Business Rules/Update Incident State To Closed/readme.md b/Server-Side Components/Business Rules/Update Incident State To Closed/readme.md new file mode 100644 index 0000000000..2dcffe73e6 --- /dev/null +++ b/Server-Side Components/Business Rules/Update Incident State To Closed/readme.md @@ -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. From 97133fd52dc6b7a9492dae80a82976993f8152a1 Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Fri, 3 Oct 2025 16:09:35 +0530 Subject: [PATCH 2/2] script.js --- .../Update Incident State To Closed/script.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Server-Side Components/Business Rules/Update Incident State To Closed/script.js diff --git a/Server-Side Components/Business Rules/Update Incident State To Closed/script.js b/Server-Side Components/Business Rules/Update Incident State To Closed/script.js new file mode 100644 index 0000000000..b4c1a854a8 --- /dev/null +++ b/Server-Side Components/Business Rules/Update Incident State To Closed/script.js @@ -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); +}