Performance Analytics Job Throwing an Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 11:14 AM
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 -
Please let me know if I am missing something here.
Regards,
Himesh
- Labels:
-
Performance Analytics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 11:39 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 12:30 PM
Thanks for the quick response,
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2022 12:54 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2022 12:22 AM
Hi
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
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