From c7c2275c1c269b73365c987635bf2a6a478e34e9 Mon Sep 17 00:00:00 2001
From: GHSayak25 <59216790+GHSayak25@users.noreply.github.com>
Date: Mon, 20 Oct 2025 19:59:03 +0530
Subject: [PATCH 1/2] Get Risks and Controls involved in a Risk Assessment
Project
---
.../README.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Server-Side Components/Background Scripts/Get Risk and Controls in Project/README.md
diff --git a/Server-Side Components/Background Scripts/Get Risk and Controls in Project/README.md b/Server-Side Components/Background Scripts/Get Risk and Controls in Project/README.md
new file mode 100644
index 0000000000..8d6e6633bb
--- /dev/null
+++ b/Server-Side Components/Background Scripts/Get Risk and Controls in Project/README.md
@@ -0,0 +1,19 @@
+In ServiceNow Risk Assessment Project, we can assess multiple risks on a single page or UI.
+But for each individual risks, we need different Controls to be associated that can mitigate the risk.
+So, there is direct relationship between Risk and Control in ServiceNow along with Risk and Risk Assessment Project.
+Two m2m tables are - 'sn_risk_m2m_risk_control' and 'sn_risk_advanced_m2m_risk_assessment_project_risk' respectively.
+
+Now organisations need to check how many Controls involved in a Risk Assessment Project for each risk.
+To achieve that, we can utilize Risk Assessment Instance Response records where Control Assessment data is stored.
+This Control Assessment data is updated whenever we associate Controls with Risks during Risk Assessment and fill out the factors.
+
+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-
+
+
+Actual Risk Assessment Project on workspace looks like this-
+
+
+
+
+
+Here, at the left we can select individual risks and inside of Control Assessment for that risk, controls can be added and assessed.
From 11dcf35761291bbfecc378dc49a6e585ba35943d Mon Sep 17 00:00:00 2001
From: GHSayak25 <59216790+GHSayak25@users.noreply.github.com>
Date: Mon, 20 Oct 2025 20:03:06 +0530
Subject: [PATCH 2/2] Get Risks and Controls that are involved for a Risk
Assessment Project
---
.../risksandcontrolsinProject.js | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 Server-Side Components/Background Scripts/Get Risk and Controls in Project/risksandcontrolsinProject.js
diff --git a/Server-Side Components/Background Scripts/Get Risk and Controls in Project/risksandcontrolsinProject.js b/Server-Side Components/Background Scripts/Get Risk and Controls in Project/risksandcontrolsinProject.js
new file mode 100644
index 0000000000..106dc038b7
--- /dev/null
+++ b/Server-Side Components/Background Scripts/Get Risk and Controls in Project/risksandcontrolsinProject.js
@@ -0,0 +1,17 @@
+var asmtGr = new GlideRecord('sn_risk_advanced_risk_assessment_instance');
+asmtGr.addQuery('risk_assessment_project','d4eed504c3787210b533bb02b4013121');//Risk Assessment Project Sys Id
+asmtGr.query();
+while(asmtGr.next()){
+ gs.print("Risk: "+asmtGr.risk.name+"\n");//Printing Individual Risk Name
+ var asmtResp = new GlideAggregate('sn_risk_advanced_risk_assessment_instance_response');
+ asmtResp.addEncodedQuery('assessment_instance_id='+asmtGr.sys_id+'^assessment_type=2^parent_instance_response=NULL');
+ asmtResp.query();
+ var countCont = asmtResp.getRowCount().toString();
+ gs.print("This risk has "+countCont+" control(s) associated as mitigating action. Those are -\n");
+ var i=1;
+ while(asmtResp.next()){
+ gs.print('Control '+i+' : '+asmtResp.control.name+"\n");//Printing Control names for each risk
+ i++;
+ }
+ gs.print('\n');
+}