Skip to content

Commit b4570b0

Browse files
Business rule: Without Attached Incident Emergency Change cannot be closed (#1050)
* Review to Close Without Incident.js While moving the emergency change request from review to close state , if there is No attached Incident to it then we will, abort the action and popup an error message. * readme.md
1 parent 939968e commit b4570b0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//before business rule is used and update only checked
2+
//conditions were type is emergency AND State changes to closed
3+
// if these conditions met and there is no attached incidents to this emergency change request then, we don't let the user to close the Change request
4+
5+
(function executeRule(current, previous /*null when async*/ ) {
6+
7+
var inc = new GlideAggregate('incident');//we glide the incident table to get the value of current change request having any incidents or not
8+
inc.addQuery("rfc", current.getUniqueValue()); //instead of sys_id we used getUniqueValue
9+
inc.query();
10+
//if any incident found then its fine and we can move it to close state
11+
..if No incident found then we will abort the action and send's a pop-up message to the user
12+
if (!inc.hasNext()){
13+
gs.addErrorMessage('Emergency change cannot be moved from review to close without an attached incident in Incidents Fixed by change');
14+
current.setAbortAction(true);
15+
}
16+
})(current, previous);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1. This is a Before-Busines rule created on Change Request Table
2+
2. I used GlideAggregate API.
3+
3. only update is checked
4+
4. conditions were Type is Emergency AND State changes to Close.
5+
5. For emergency change Request, if there are no attached incident's to it then we don't let the user to move the state to close.
6+
6. We use glideAggregate to glide Incident table and if we find any incident's user can move the state to close, But if there is no records then user action will be aborted.

0 commit comments

Comments
 (0)