How to get Highest Impact Value of an Incident that are assocaited with Change Number

Murugan Arumuga
Tera Contributor

I have a set of change numbers and multiple incidents with different Impact been tagged to each Change Numbers. I want to get the unique count of incident which has highest impact value. 

 

For Eg.,

The CHG0001234 is associated with below incidents :

INC0001234 >> 4 - Minor / Localized

INC0002234 >> 4 - Minor / Localized

INC0001254 >> 4 - Minor / Localized

INC0001233 >> 5 - No Impact / Single User

INC0001233 >> 3 - Moderate / Limited

INC0002233 >> 3 - Moderate / Limited

 

From the above i want to get highest Impact as  "3 - Moderate / Limited" with distinct Incident count.

I'm using Indicator source and indicators. From the Incident table, i m picking "Causedby Change" as distinct count where i m getting list of change # and incident that were associated to that. I want to report unique count of incident with highest impact that tagget to the CR.

Let me know this can be done with script or relation table.

 

6 REPLIES 6

Thian Jin1
Tera Contributor

I am having the similar issue and looking for similar solution.

 

Applying Count Distinct on the Change Number field, the score is returning the unique count by change number. Perhaps scripted indicator that identify the highest impact value 3 would be needed. 

 

Help needed.

Community Alums
Not applicable

Hi @Murugan Arumuga  and @Thian Jin1 ,

Please check this script below this gives the incident number with impact low

 

var gr = new GlideRecord('incident');
gr.addQuery('parent', '87b1682a0a0a2c3e75af785bd9073d70'); // sysId of change record which is parent of incident 
gr.addQuery('impact', 3);
gr.query();
while(gr.next()){
	gs.print('Incident Number with low impact  = ' + gr.number);
}

 

 

SarthakKashya2_0-1714037316503.png

 

 

Please let me know if you need me in something regarding this

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards

Sarthak

Hi @Community Alums,

Thanks for the response,

I am thinking that the solution should be able to iterate over the group of similar change number from the incident table such as below to distinctly count the change number that has the lowest Final Impact. 

Result for

Lowest final Impact = 1 is 1 change(s)

Lowest final Impact = 2 is 2 change(s)

Lowest final Impact = 3 is 0 change(s)

 

ThianJin1_0-1714041889687.png

I am also trying to create a Performance Analytic Scripted Indicator with the following, but it is not processing. Could you advise? Thanks. 

 

 

// Define the indicator function
function calculateIndicator(incGR) {
    var changeNumbers = {}; // Object to store change numbers and their corresponding minimum impact values

    var incidentGr = new GlideRecord('incident'); // Query the Incident table
    incidentGr.addEncodedQuery('caused_by='+incGR.causedby); // Only active incidents
    incidentGr.query();

    // Loop through the incidents
    while (incidentGr.next()) {
        var changeNumber = incidentGr.getValue('caused_by');
        var impact = parseInt(incidentGr.getValue('u_final_impact')); // Assuming 'impact' is a numeric field

        if (!changeNumbers[changeNumber] || impact < changeNumbers[changeNumber]) {
            changeNumbers[changeNumber] = impact;
        }
    }

    // Find the change numbers with the lowest impact value of 2
    var lowestImpactChangeNumbers = [];
    for (var cn in changeNumbers) {
        if (changeNumbers[cn] === 2) {
            lowestImpactChangeNumbers.push(cn);
        }
    }

    return lowestImpactChangeNumbers;
}

// Call the indicator function
calculateIndicator(current.caused_by);