Skip to content

Commit 89cec72

Browse files
authored
Create scriptBR.js
1 parent 4d95501 commit 89cec72

File tree

1 file changed

+21
-0
lines changed
  • Server-Side Components/Business Rules/Abort Parent Incident Closure When Child is Open

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
// Query for any child incidents related to the current parent incident.
4+
var childIncidents = new GlideRecord('incident');
5+
childIncidents.addQuery('parent_incident', current.sys_id);
6+
childIncidents.addEncodedQuery('state!=6^ORstate!=7^ORstate!=8'); // state is not closed,Resoved,cancelled
7+
childIncidents.addActiveQuery();
8+
childIncidents.query();
9+
// Check if any open child incidents were found.
10+
if (childIncidents.getRowCount() > 0) {
11+
var childNumbers = [];
12+
while (childIncidents.next()) {
13+
childNumbers.push(childIncidents.number.toString());
14+
}
15+
// Display an error message with the open child incident numbers.
16+
gs.addErrorMessage('Cannot close this incident. Please close the following child incidents first: ' + childNumbers.join(', '));
17+
//prevent saving the record
18+
current.setAbortAction(true);
19+
}
20+
21+
})(current, previous);

0 commit comments

Comments
 (0)