- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 11:48 AM - edited 03-12-2024 12:07 PM
We're trying to show the number of pending approvals weekly by age ranges, a snapshot of what was pending approval on that given date. We have quite a few months that are missing data, and the greater than 2 months range has the same number for several weeks. I'm not sure what I'm missing here. 😞
Widget
Indicator
Indicator Source
Bucket Group
Breakdown
Breakdown Mapping
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 01:11 AM
Hi @alhicks ,
Sorry for the late reply, had some work to be done prior to my respond. If you would like to see if the approval time has improved, you need to look into how long it has taken from requested to approved.
This can be completed by creating a metric definition on the sysapproval_approver table. As you see below I created below in my PDI:
With below script to complete the population:
if (current.state.toLowerCase() === 'approved') {
createMetric();
}
function createMetric() {
var mi = new MetricInstance(definition, current);
var gr = mi.getNewRecord();
gr.field_value = current.state;
var start = new GlideDateTime(current.sys_created_on);
var end = new GlideDateTime(current.sys_updated_on);
gr.start = start;
gr.end = end;
// Calculate duration in milliseconds
var durationMillis = Math.abs(start.getNumericValue() - end.getNumericValue());
// Convert milliseconds to duration string
var durationString = durationToTimeString(durationMillis);
gr.duration = durationString;
gr.calculation_complete = true;
gr.insert();
}
// Function to convert milliseconds to duration string
function durationToTimeString(durationInMillis) {
var seconds = Math.floor(durationInMillis / 1000);
var minutes = Math.floor(seconds / 60);
var hours = Math.floor(minutes / 60);
seconds = seconds % 60;
minutes = minutes % 60;
return pad(hours) + ':' + pad(minutes) + ':' + pad(seconds);
}
// Function to pad single digits with leading zero
function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
This will provide the result:
Please note, for the metric to be populated, you need to go to metrics --> business rule:
Make a copy of the metrics events (see top row):
and just correct the task table to sysapproval_approver for the new business rule:
The reason that you need to do this is, that the metrics event runs on the task table, but the sysapprover_approval is not extended from task table.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 07:46 AM
Hi @alhicks ,
No - it's fine.
Basic, my thought would be one widget for count pf pending approvals by month with a breakdown of age in bucket groups. The only question that you need to clarify is, if you would like to capture data daily or only monthly.
Let's say you have a approval coming in on 5th and approved by 10th - should this be shown by pending approval 6th, 7th, 8th, 9th or should it be left out because approval was prior to month end?
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 12:30 PM
I think ideally we'd like to see the widget in a monthly view and only show the number of approvals that were still pending at the end of that month.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 11:51 PM
Hi @alhicks ,
All right, then your condition should look something like below with a monthly data collection.
State is requested and
requested on this month and
Approval for type is requested item or
Approval for type is change request
Above will give you the view that you're looking for.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2024 10:24 AM
Thank you so much. This looks correct to me, if it's ok I'll get my manager to look at the data and let you know tomorrow. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 12:00 AM
Hi @alhicks ,
Sure, no problem - let me know how it goes.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/