Performance Analytics Job Throwing an Error

Himesh Murthy
Tera Contributor

Hello All,

I have a requirement to get the total number of incidents being resolved within 15 minutes of their creation using PA Indicator which will in turn be used in the formula Indicator to calculate further based on needs. 

I've created the below script in the Global application but the PA job throws following error - "Error during JavaScript evaluation com.snc.pa.dc.ScriptException: JavaScript evaluation returned: Undefined in script"

var getRecords = function() {
var created = current.sys_created_on;
var resolved = current.resolved_at;
var diff = gs.dateDiff(created, resolved, true);
var toMins = diff / 60;
var mins = parseInt(toMins);
if (mins < 15) {
return mins;
}
};

getRecords();

 

Indicator Created -

find_real_file.png

Please let me know if I am missing something here. 

 

Regards,

Himesh

5 REPLIES 5

Dan H
Tera Guru

It's probably due to the fact that the function is not returning any value if: 'mins' > 15.

You could check if thats the cause by trying this as the script:

var getRecords = function () {
  var created = current.sys_created_on;
  var resolved = current.resolved_at;
  var diff = gs.dateDiff(created, resolved, true);
  var toMins = diff / 60;
  var mins = parseInt(toMins);
  if (mins < 15) {
    return mins;
  } else {
    return 0;
  }
};

getRecords();

 

Hope this helps.

 

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

Thanks for the quick response, @Dan H . I did not encounter the error again after using the above script of yours but I do see incorrect data shown in the scoresheet of the indicator.

There are 6 incidents that were resolved within 15 minutes after their creation but the scoresheet shows the count 4. 

Do I have to do any other changes outside of the script to fix this?

 

Regards,

Supreeth R

 

 

I would probably add some logs to the script to see what is happening with each record and seeing how you are ending up with 4 instead of 6.

You'll be able to see which records are being used in the function etc.

var getRecords = function () {
  var created = current.sys_created_on;
  var resolved = current.resolved_at;
  var diff = gs.dateDiff(created, resolved, true);
gs.log('[DEBUG] diff for ' + current.number + ' is: ' + diff);
  var toMins = diff / 60;
  var mins = parseInt(toMins);
gs.log('[DEBUG] mins for ' + current.number + ' is: ' + mins);
  if (mins < 15) {
    return mins;
  } else {
    return 0;
  }
};

getRecords();

Hope this helps

Hi @Dan H,

Few things that I noticed lately

1) 4 Job warnings saying - 'No data was collected between 2019-03-15 and 2020-03-11 for indicator source "Incidents.State.Resolved". Data within this range is older than the maximum age, based on indicator frequency and collection periods, for all indicators associated with this indicator source' are encountered every time the job is run

2) Duplicate logs have been captured at the same time for multiple Incidents as shown the screenshot below

 

find_real_file.png

 

find_real_file.png

 

The issue with the incorrect scoresheet still persists but I am not able to find the root cause for it. What could have possibly gone wrong here? Please suggest