ServiceNow Performance Analytics Query

Alpha_K
Tera Contributor

Hi All,

 

I have a requirement in Performance  Analytics. 

 

Requirement:

Table: Incident Table.

Conditions are:

Priority is P1

Major incident state is accepted.

classification is Apps 

Created at or after Jan2023

when all these conditions are met,

 

Alpha_K_0-1745916174029.png

we need to update the days since Apps P1 Incident.

 

Alpha_K_2-1745916413700.png

 

 

How the days I am updating now is manually 

Going to the incident table 

Giving all these queries in the filter 

Then running the query

Created date (sort z to a) and then updating the days

 

 

 

I have been trying with the basic reporting and Performance Analytics where I am getting the overall count of the incident in a single score or if i try with any other type in reporting I am getting the counts.

 

Here the requirement is we need to calculate the days created date(sort z to a) and then need to update the days

 

Analysis Done:

I have been trying this requirement on Performance Analytics, 

Initially I have created a business rule 

Named: Apps

Table : Incident.

when to Run: After 

Insert : checked

Update: checked

Filter conditions Applied :

Alpha_K_3-1745916456619.jpeg

 

 

I have created a custom tabled name" u_reporting_look_up_table".

 

Advanced:

(function executeRule(current, previous /*null when async*/ ) {

 

    var gr = new GlideRecord('incident');

    gr.addQuery('priority', 1);

   // gr.addQuery('u_organization_type', App);

    gr.orderByDesc('sys_created_on');

    gr.setLimit(1);

    gr.query();

 

    if (gr.next()) {

        // Update the custom reference field in the custom table with the latest P1 Incident

        var latestP1Incident = gr.sys_id;

        var customTableGr = new GlideRecord('u_reporting_look_up_table');

        customTableGr.get('667e71001b78a290d8f6968f034bcb53'); // Replace with the sys_id of the record you want to update

        customTableGr.u_number = latestP1Incident;

        customTableGr.update();

    }

})(current, previous);

 

where in that table I am getting the days since p1 incidents .

Alpha_K_4-1745916456609.jpeg

 

I have executed the scheduled job and was trying to get output but it did not display any result.

 

 

Is there any way that this can be done automatically via PA or any other way that this requirement can be achieved?

Please suggest

 

 

 

0 REPLIES 0