|
1 | 1 | (function executeRule(current, previous /*null when async*/ ) { |
2 | 2 | // This Business Rule runs 'before' a record is updated on the 'sn_compliance_policy' table. |
3 | | - // Its purpose is to prevent a policy from being retired if it is currently linked to any active controls. |
4 | | - // This enforces a proper decommissioning process, ensuring that controls are retired |
| 3 | + // Its purpose is to prevent a policy from being retired if it is currently linked to any active Control Objective. |
| 4 | + // This enforces a proper decommissioning process, ensuring that Control Objective are delinked. |
5 | 5 | // before the policy that governs them, thereby preventing compliance gaps. |
6 | 6 | // The condition for this rule would be: 'State' changes to 'Retired'. |
7 | 7 |
|
|
18 | 18 |
|
19 | 19 | // Add a second query using 'dot-walking' to filter for records where the related |
20 | 20 | // control statement ('content' field) is currently active. This ensures only active |
21 | | - // controls are considered. |
| 21 | + // Control Objective are considered. |
22 | 22 | grControlAggregate.addQuery('content.active', true); |
23 | 23 |
|
24 | 24 | // Set the aggregate function to COUNT. This tells the database to return the total |
|
28 | 28 | // Execute the database query. |
29 | 29 | grControlAggregate.query(); |
30 | 30 |
|
31 | | - // Initialize a variable to store the count of active controls. |
| 31 | + // Initialize a variable to store the count of active Control Objective. |
32 | 32 | var activeControlCount = 0; |
33 | 33 |
|
34 | 34 | // Check if the query returned any results. If it did, retrieve the count. |
|
38 | 38 | activeControlCount = grControlAggregate.getAggregate('COUNT'); |
39 | 39 | } |
40 | 40 |
|
41 | | - // Check if the count of active controls is greater than zero. |
| 41 | + // Check if the count of active Control Objective is greater than zero. |
42 | 42 | if (activeControlCount > 0) { |
43 | | - // If active controls were found, add an error message to display to the user. |
| 43 | + // If active Control Objective were found, add an error message to display to the user. |
44 | 44 | // The message includes the count for better clarity. |
45 | | - gs.addErrorMessage('Cannot retire this policy because it has ' + activeControlCount + ' active controls linked to it. All controls must be retired first.'); |
| 45 | + gs.addErrorMessage('Cannot retire this policy because it has ' + activeControlCount + ' active Control Objective linked to it. All Control Objective must be delinked first.'); |
46 | 46 |
|
47 | 47 | // This crucial line aborts the current database transaction (the update operation). |
48 | 48 | // It prevents the policy record from being marked as 'Retired'. |
|
0 commit comments