- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We calculate three SAM KRI scores by grouping eligible Software Discovery Models into unique Product and Edition combinations and matching them against version-independent Software Models.
The calculation requires cross-table matching and duplicate handling, so a Script Include writes the results to three manual PA indicators. The scores and dashboard are working, but Show Records is unavailable because the manual indicators do not contain supporting record snapshots.
We need users to select each metric and see the exact unique records contributing to the score. For example, a Product Owner score of 7 should drill down to exactly those 7 unique products.
Is there a supported method to associate supporting records with scripted manual scores, or to use an automated or scripted indicator source that collects one record per unique Product and Edition combination without creating a custom detail table?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @pavan Punna -
If you are building complex metrics in ServiceNow Performance Analytics such as cross-table matching or grouping unique combinations you have likely discovered that Manual Indicators do not support the "Show Records" drill-down functionality. Because manual indicators don't utilize the pa_snapshots table, there are no underlying records to display.
Furthermore, if you try to use an Automated Indicator with a "Count Distinct" aggregation, the score will be correct, but clicking "Show Records" will display all the underlying records that contributed to the count, not just the unique ones.
in your case I think you can achieve a perfect 1:1 match between your score and your drill-down records by using an Automated Indicator paired with a Script Include in the Indicator Source condition. By using the javascript: syntax, you can pre-filter the exact unique records before the PA engine collects them, completely bypassing the need for custom detail tables or manual indicators.
Here is an example - Calculating Software Asset Management KRI scores. You need to group eligible Software Discovery Models into unique Product and Edition combinations. If your unique count is 7, your Product Owners expect to click that score and see exactly 7 unique records.
Here is the step-by-step guide on how to architect this solution.
Step 1: Create the Script Include
Instead of relying on PA to do the deduplication, we will use a Script Include to do the complex cross-table matching and duplicate handling.
Create a client-callable Script Include (or one accessible by the System user). This script will query your table, group the records by your unique criteria, select exactly one representative sys_id for each unique group, and return them as a comma-separated string.
var SAMKRIRecordHelper = Class.create();
SAMKRIRecordHelper.prototype = {
initialize: function() {},
getUniqueDiscoveryModels: function() {
var uniqueSysIds = [];
// 1. Query eligible Software Discovery Models
// 2. Match against version-independent Software Models
// 3. Group by Product + Edition
// 4. Push exactly ONE sys_id per unique group into the array
// (Insert your GlideAggregate or GlideRecord logic here)
return uniqueSysIds.join(',');
},
type: 'SAMKRIRecordHelper'
};Step 2: Configure the Indicator Source - This will be the filter
Next, create a new Indicator Source pointing to your target table (e.g., Software Discovery Models). Instead of standard condition builder rules, we will call our script.
- In the Conditions builder, set the filter to: [Sys ID] [is one of] [javascript:new SAMKRIRecordHelper().getUniqueDiscoveryModels()]
Developer Warning: The PA Data Collector job runs in the background as the "System" user. Ensure your Script Include does not rely on session-specific data like gs.getUserID(), as it will not evaluate to the user viewing the dashboard.
Step 3: Configure the Automated Indicator - This acts as the collector
Finally, set up your Automated Indicator to collect the data.
- Link it to the new Indicator Source you just created.
- Set the Aggregate to Count (Do NOT use Count Distinct, as your script has already done the deduplication!).
- Check the Collect records checkbox on the indicator form.
So, when the PA Data Collector job runs, it evaluates the Indicator Source condition first. Your script executes and hands the PA engine an exact list of 7 sys_ids. PA counts these 7 records, generates a score of 7, and saves those exact 7 records into the pa_snapshots table.
When your users click "Show Records" on the Analytics Hub or Dashboard, they get exactly what they asked for: the exact unique records contributing to the score, with no duplicates and no custom tables required.
Please ACCEPT the solution if above response helped you to resolve the issue. Thank you !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @pavan Punna -
If you are building complex metrics in ServiceNow Performance Analytics such as cross-table matching or grouping unique combinations you have likely discovered that Manual Indicators do not support the "Show Records" drill-down functionality. Because manual indicators don't utilize the pa_snapshots table, there are no underlying records to display.
Furthermore, if you try to use an Automated Indicator with a "Count Distinct" aggregation, the score will be correct, but clicking "Show Records" will display all the underlying records that contributed to the count, not just the unique ones.
in your case I think you can achieve a perfect 1:1 match between your score and your drill-down records by using an Automated Indicator paired with a Script Include in the Indicator Source condition. By using the javascript: syntax, you can pre-filter the exact unique records before the PA engine collects them, completely bypassing the need for custom detail tables or manual indicators.
Here is an example - Calculating Software Asset Management KRI scores. You need to group eligible Software Discovery Models into unique Product and Edition combinations. If your unique count is 7, your Product Owners expect to click that score and see exactly 7 unique records.
Here is the step-by-step guide on how to architect this solution.
Step 1: Create the Script Include
Instead of relying on PA to do the deduplication, we will use a Script Include to do the complex cross-table matching and duplicate handling.
Create a client-callable Script Include (or one accessible by the System user). This script will query your table, group the records by your unique criteria, select exactly one representative sys_id for each unique group, and return them as a comma-separated string.
var SAMKRIRecordHelper = Class.create();
SAMKRIRecordHelper.prototype = {
initialize: function() {},
getUniqueDiscoveryModels: function() {
var uniqueSysIds = [];
// 1. Query eligible Software Discovery Models
// 2. Match against version-independent Software Models
// 3. Group by Product + Edition
// 4. Push exactly ONE sys_id per unique group into the array
// (Insert your GlideAggregate or GlideRecord logic here)
return uniqueSysIds.join(',');
},
type: 'SAMKRIRecordHelper'
};Step 2: Configure the Indicator Source - This will be the filter
Next, create a new Indicator Source pointing to your target table (e.g., Software Discovery Models). Instead of standard condition builder rules, we will call our script.
- In the Conditions builder, set the filter to: [Sys ID] [is one of] [javascript:new SAMKRIRecordHelper().getUniqueDiscoveryModels()]
Developer Warning: The PA Data Collector job runs in the background as the "System" user. Ensure your Script Include does not rely on session-specific data like gs.getUserID(), as it will not evaluate to the user viewing the dashboard.
Step 3: Configure the Automated Indicator - This acts as the collector
Finally, set up your Automated Indicator to collect the data.
- Link it to the new Indicator Source you just created.
- Set the Aggregate to Count (Do NOT use Count Distinct, as your script has already done the deduplication!).
- Check the Collect records checkbox on the indicator form.
So, when the PA Data Collector job runs, it evaluates the Indicator Source condition first. Your script executes and hands the PA engine an exact list of 7 sys_ids. PA counts these 7 records, generates a score of 7, and saves those exact 7 records into the pa_snapshots table.
When your users click "Show Records" on the Analytics Hub or Dashboard, they get exactly what they asked for: the exact unique records contributing to the score, with no duplicates and no custom tables required.
Please ACCEPT the solution if above response helped you to resolve the issue. Thank you !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you Vijay for the suggested approach. I implemented the Script Include, dynamic Sys ID is one of javascript:... Indicator Sources, automated indicators with Count, and Collect records enabled.
The automated scores are correct, and the expected sys_id values are stored in pa_snapshots. For example:
Denominator score: 1,264
Unique snapshot sys_ids: 1,264
KPI Details Show Records: 1,174
Software Model numerator score: 142
Unique snapshot sys_ids: 142
KPI Details Show Records: 52
All snapshot records still exist and are readable, the snapshot limit is 60,000, the collection job has no warnings or errors, and there are no additional indicator conditions. I also set the KPI Details start and end dates to the same daily collection date, but the displayed record counts did not change.
Have you encountered KPI Details displaying fewer records than the pa_snapshots population? Is there another filter or PA configuration that Show Records applies when rendering the collected records?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I did not encounter the issue of fewer records. My data is not as extensive as yours. I am not aware of any other PA configuration.
I am pleased to learn that the provided information has been helpful. If the above post was of assistance, please consider accepting the solution.