Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Kindly help me with below requirement

keval3
Tera Contributor

Hi Team,

 

I have below requirement.. there is one custom table call Ldoc in witch there are one field called Milestone with choice list type it is basically works like state field. basically I want to create new field called TAT where I can show the timing of Milestone changing time. please let me know how to do it. kindly find below screen snap for same.

I want to create that field because I want to create report where I will have to capture the Timing.

 

 

keval3_1-1738085381571.png

 

Thanks & Regards

KP

 

 

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @keval3 

 

I am not 100% sure, but will SLA not work for you here?

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

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

Gummagatta Hars
Mega Guru

Hi @keval3 ,

 

If your end goal is to create a report which displays the duration which captures of Milestone field changes, I would suggest to create a Metric Definition on the custom table with below values instead of a new field.

 

Name : Name of metric

Table : Your custom table

Field : Milestone

Type :  Field value duration

 

This will create a metric instance[metric_instance] whenever there is a change in Milestone value. If this suggestion helps you please accept the solution and mark the answer as helpful.

 

Thanks,

Gummagatta Harshavardhana

 

Hi  Gummagatta

I have created metric and it works but i want ldoc no in my report witch was my custom table no I have created report on Matric table. I wanted to add below things in my report kindly let me know how to do it.

keval3_0-1738154103085.png

 

 

Hi @keval3 ,

 

To store the Idoc number in the value of metric instance, change the calculation type to script calculation and in the script field add the below script.

 

Update this line  gr.value = current.Idoc.getDisplayValue(); with the field which stores your Idoc number.

 

If this suggestion helps you please accept the solution and mark the answer as helpful.

createMetric(true);

function createMetric(value) {

    var mi = new MetricInstance(definition, current);
   
        var gr = mi.getNewRecord();
        gr.start = current.sys_created_on;
        gr.end = gs.nowDateTime();
        var gdt1 = new GlideDateTime(current.sys_updated_on);
        var gdt2 = new GlideDateTime();
        gr.duration = gs.dateDiff(gdt1.getDisplayValue(), gdt2.getDisplayValue(), false);
        gr.value = current.Idoc.getDisplayValue();
        gr.calculation_complete = true;
        gr.insert();
   

}

 

 Thanks,

Harsha Gummagatta