Change Risk Assessment Metric Query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 12:34 AM
Hi All,
By using Risk Assessment Metric Script option can we achieve the below requirement?
Count the number of impacted CI's on the change related list called "Impacted CI's" and return the relevant value.
If the count is between 1 to 5 then select 1 to 5 option on the metric.
If the count is between 1 to 6 then select 6 to 10 option on the metric.
Thanks & Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2024 02:38 AM
Hi @Dr Atul G- LNG ,
Yes, it is to calculate the Risk for Change. Could you please check if the below script is correct?
var ciCount = new GlideAggregate('task_cmdb_ci_service');
ciCount.addQuery('task', primary);
ciCount.addAggregate('COUNT');
ciCount.query();
if (ciCount.next()) {
var actual_result = ciCount.getAggregate('COUNT');
if (actual_result >= 1 && actual_result <= 5) {
scaled_result = 20;
} else if (actual_result >= 6 && actual_result <= 10) {
scaled_result = 40;
}
}
scaled_result = 60;
Thanks & Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2024 03:17 AM
Hello @Joshuu ,
Please give a try to the script below and let me know how it works for you.
var ciCount = new GlideAggregate('task_cmdb_ci_service');
ciCount.addQuery('task', primary);
ciCount.addAggregate('COUNT');
ciCount.query();
var scaled_result = 60; // Default value
if (ciCount.next()) {
var actual_result = ciCount.getAggregate('COUNT');
if (actual_result >= 1 && actual_result <= 5) {
scaled_result = 20;
} else if (actual_result >= 6 && actual_result <= 10) {
scaled_result = 40;
} else if (actual_result > 10) {
// You might want to handle cases where the count is greater than 10
// Add your logic here based on the specific business requirements
scaled_result = 60;
}
}
// Now you can use the 'scaled_result' variable as needed for your risk assessment metric.
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2024 12:26 AM
Hi @Aniket Chavan ,
This is working as expected and Risk is getting calculated.
But the question on the risk assessment form. What data type do we need to consider for this question.
Because we want to show on the risk form as below.
Either it should be the exact count of impacted CIs or it should be like 1-5/5-10/>10. But not the value like 20/40/60.
Now, if I use Number data type it is showing as below
Could you please suggest how to achieve this?
I have tried using 'string_result' in the script but it is not working as expected.
Thanks & Regards.