Change Risk Assessment Metric Query

Joshuu
Kilo Sage

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.

 

 

7 REPLIES 7

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.

 

Aniket Chavan
Tera Sage
Tera Sage

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

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.

 

priyarao_0-1706257287006.png

priyarao_1-1706257385270.png

 

 

Now, if I use Number data type it is showing as below

 

priyarao_2-1706257506484.png

 

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.