Skip to content

Commit 58d5eb4

Browse files
Create script.js
Business rule script to validate CI on deployed assets and send an email notification to user's manager if the asset is not linked to a CI.
1 parent 8dc115e commit 58d5eb4

File tree

1 file changed

+24
-0
lines changed
  • Business Rules/Validate CI on deployed assets

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
4+
// Only act if asset is deployed and has no CI
5+
if (current.install_status == 'Deployed' && !current.ci) {
6+
// Get the user assigned to the asset
7+
var userGR = new GlideRecord('sys_user');
8+
if (userGR.get(current.assigned_to.toString())) {
9+
var manager = userGR.manager;
10+
if (manager) {
11+
// Send notification to manager
12+
gs.eventQueue('asset.ci.missing', current, manager.toString(), current.assigned_to.toString());
13+
gs.info("[Asset-CI Check] Notification sent to manager: " + manager.name);
14+
} else {
15+
gs.info("[Asset-CI Check] Assigned user has no manager.");
16+
}
17+
} else {
18+
gs.info("[Asset-CI Check] Assigned user not found.");
19+
}
20+
}
21+
22+
23+
24+
})(current, previous);

0 commit comments

Comments
 (0)