HR Metric Help

Danielle10
Tera Contributor

Good day!

New metric for when an HR Case is opened until the HR Case hits the awaiting acceptance state?

 

Thank you for your help!

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi @Danielle10,

 

Please find the below screenshot and script that will help achieve this for you (Tried and tested on the HR table on my PDI - Personal Dev Instance).

 

Please note @Danielle10 - This Metric will only be created when the HR Case is saved in the state of 'Awaiting Acceptance'. (And not before)

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

Screenshot (A new 'Metric Definition')

Screenshot 2024-03-12 at 17.54.29.png

Script: 

 

// variables available
// current: GlideRecord -  target incident
// definition: GlideRecord -  (this row)
var s = current.state;
if (s == 20)
  createMetric();

function createMetric() {
  var mi = new MetricInstance(definition, current);
  if (mi.metricExists()) 
    return; 

  var hrCaseAwaitAcc = mi.getNewRecord();
  hrCaseAwaitAcc.start = current.sys_created_on;
  hrCaseAwaitAcc.end = current.sys_updated_on;
  hrCaseAwaitAcc.duration = gs.dateDiff(hrCaseAwaitAcc.start.getDisplayValue(), hrCaseAwaitAcc.end.getDisplayValue());
  hrCaseAwaitAcc.calculation_complete = true;
  hrCaseAwaitAcc.insert();
}

 

 

 

 

 

View solution in original post

13 REPLIES 13

Hi @Danielle10 

 

No need to add start / end time. once you save this metric and update the HR case then it capture automatically.

AGLearnNGrow_0-1710255251111.png

 

*************************************************************************************************************
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]

****************************************************************************************************************

This will require scripting to appropriately capture the start and end points. Any idea on how to formulate this script?

NO scripting at all, system will do all calculation for you.

*************************************************************************************************************
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]

****************************************************************************************************************

Danielle10
Tera Contributor

Thank you.

put HR table instead of Incident 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]

****************************************************************************************************************