PA Real Time Score using scripted indicator aggregation

diogo_ramos
Mega Expert

Hello Everyone,

I'm having a little problem with the following, I want to create a score where the type needs to be Real Time, my indicator runs on a time worked table [task_time_worked] and has the following columns: find_real_file.png

What I'm looking for is to create a widget that follows a breakdown (with a whitelist on the sys_user table) that is added to the dashboard and an user can select other users and it will then display time worked in hours for the chosen user. I have this working fine for non real time widgets, in the Indicator I just have :

Aggregate (SUM)

Scripted = true (the script picks up the time in seconds field and returns the time in hours)

The problem with the above is that we don't have the Show real-time score option when we use a script in the indicator aggregation, I'm looking if someone has any idea to get this work, I know I can just use a report but the problem is that I have to have the report following the breakdown selection so it shows the time worked at the time for the selected user.

I appreciate any help.

Cheers,

Diogo

Edit: I was able to get this working with normal reports, I made an interactive filter and add it to the dashboard breakdown, although it does not look as good as it would with a score widget.

3 REPLIES 3

Adam Stout
ServiceNow Employee
ServiceNow Employee

I'm not sure what version you are looking at now, but you may want to check out the new Kingston Glide Functions which can do this calculation without a script in reporting and in PA.  



Using function fields to perform database operations


Nandhu1704
Tera Contributor

Hi @Adam Stout,

 

We have configured surveys in service request and trying to calculate the nps score. So, initially we have to aggregate the unique value of RITMS and get sum of actual values. Below is my script that I am trying to do. But I don't know where I have missed it's not working. Kindly assist

Nandhu1704_0-1734349247539.png

 

 

function execute(){
var ga = new GlideAggregate('u_sctask_assessment_detail');
// Group by RITM
ga.groupBy('asmtins_task_id');
ga.query();
var totalUniqueRITMs = 0;
var totalActualValue = 0;
// Iterate through unique RITMs
while (ga.next()) {
   totalUniqueRITMs++;
   // Fetch the first actual value for the current RITM using GlideRecord
   var gr = new GlideRecord('u_sctask_assessment_detail');
   gr.addQuery('asmtins_task_id', ga.getValue('asmtins_task_id')); // Match the RITM
   gr.query();
   if (gr.next()) {
       var actualValue = parseFloat(gr.getValue('metricres_actual_value'));
       return actualValue;
   }}
}

Nandhu,

First, you know you are commenting on a 6-year-old thread, right? Adam has a different set of responsibilities now.
Second, I am not quite clear whether you are trying to show real-time scores sensu stricto in a PA widget or data visualisation. According to the documentation, this is not supported for scripted aggregations.

jeffrubinoff_0-1734351928815.png