Skip to content

Commit 6ad8423

Browse files
authored
Codesnippet - Get all risks and controls in risk assessment project (#2344)
* Get Risks and Controls involved in a Risk Assessment Project * Get Risks and Controls that are involved for a Risk Assessment Project
1 parent 6ccab1b commit 6ad8423

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
In ServiceNow Risk Assessment Project, we can assess multiple risks on a single page or UI.
2+
But for each individual risks, we need different Controls to be associated that can mitigate the risk.
3+
So, there is direct relationship between Risk and Control in ServiceNow along with Risk and Risk Assessment Project.
4+
Two m2m tables are - 'sn_risk_m2m_risk_control' and 'sn_risk_advanced_m2m_risk_assessment_project_risk' respectively.
5+
6+
Now organisations need to check how many Controls involved in a Risk Assessment Project for each risk.
7+
To achieve that, we can utilize Risk Assessment Instance Response records where Control Assessment data is stored.
8+
This Control Assessment data is updated whenever we associate Controls with Risks during Risk Assessment and fill out the factors.
9+
10+
In the Background script, if we pass one sys_id of Risk Assessment Project record, that should print Risks and Controls for each risk like this-
11+
<img width="767" height="356" alt="image" src="https://github.com/user-attachments/assets/56e2a719-b767-456d-959d-e84457d31c44" />
12+
13+
Actual Risk Assessment Project on workspace looks like this-
14+
15+
<img width="922" height="412" alt="image" src="https://github.com/user-attachments/assets/c102d444-922b-44ec-9cb4-4a4ae13db4c7" />
16+
17+
<img width="920" height="416" alt="image" src="https://github.com/user-attachments/assets/48f8d6b1-bb25-4d5c-875c-ca49bd6660a8" />
18+
19+
Here, at the left we can select individual risks and inside of Control Assessment for that risk, controls can be added and assessed.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var asmtGr = new GlideRecord('sn_risk_advanced_risk_assessment_instance');
2+
asmtGr.addQuery('risk_assessment_project','d4eed504c3787210b533bb02b4013121');//Risk Assessment Project Sys Id
3+
asmtGr.query();
4+
while(asmtGr.next()){
5+
gs.print("Risk: "+asmtGr.risk.name+"\n");//Printing Individual Risk Name
6+
var asmtResp = new GlideAggregate('sn_risk_advanced_risk_assessment_instance_response');
7+
asmtResp.addEncodedQuery('assessment_instance_id='+asmtGr.sys_id+'^assessment_type=2^parent_instance_response=NULL');
8+
asmtResp.query();
9+
var countCont = asmtResp.getRowCount().toString();
10+
gs.print("This risk has "+countCont+" control(s) associated as mitigating action. Those are -\n");
11+
var i=1;
12+
while(asmtResp.next()){
13+
gs.print('Control '+i+' : '+asmtResp.control.name+"\n");//Printing Control names for each risk
14+
i++;
15+
}
16+
gs.print('\n');
17+
}

0 commit comments

Comments
 (0)