Change Request total Onhold duration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:18 PM
Hi There,
There is requirement, to calculate total On Hold duration of Change Request.
If Change is On hold for X days in Assess state and moved to Authorize state.
In Authorize state change is On hold for Y days and moved to Scheduled State.
In Scheduled state change is On Hold for Z days and moved to Implement state.
Now need to calculate total On Hold duration in one field.
Total Duration = X + Y + Z
Can any one suggest me..
Below is the script I tried using before BR
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 07:21 AM
I will suggest
create 3 SLA with 3 different state & onhold conditions
and at last get a report on one table.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 08:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 04:01 AM
According to me and without code this is the only option,. else need to write big code.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 10:46 PM
Hello,
I think you are on the right track however, you'd need to handle GlideRecord and GlideAggregate separately. Please try with the following revised script,
var aggregate = new GlideAggregate('change_request');
aggregate.addAggregate('SUM', 'assess_u_duration');
aggregate.addAggregate('SUM', 'authorize_u_duration');
aggregate.addAggregate('SUM', 'scheduled_u_duration');
aggregate.addAggregate('SUM', 'implement_u_duration');
aggregate.addQuery('On hold', 'true');
aggregate.query();
while (aggregate.next()) {
var totalDuration = 0;
totalDuration += parseInt(aggregate.getAggregate('SUM', 'assess_u_duration'));
totalDuration += parseInt(aggregate.getAggregate('SUM', 'authorize_u_duration'));
totalDuration += parseInt(aggregate.getAggregate('SUM', 'scheduled_u_duration'));
totalDuration += parseInt(aggregate.getAggregate('SUM', 'implement_u_duration'));
var changeRequestGR = new GlideRecord('change_request');
changeRequestGR.get(aggregate.sys_id);
changeRequestGR.setValue('u_total_on_hold_duration', totalDuration);
changeRequestGR.update();
gs.info('Change request ' + changeRequestGR.number + ' total on-hold duration: ' + totalDuration);
}
Kindly mark correct or helpful if there's any value in the script above. I'd appreciate it!