How to diff of two Date& Time fields using FAFR

How to diff of two Date& Time fields using FAFR

If you have two date and time additional fields or default fields, and if you want to capture the difference between those two fields in Hours and minutes, then use the below script to capture the value in an additional field,

Under the respective Incident/Change template FAFR,provide the necesary criteria and  under Actions, select Execute script and provide the below script,

var x=$CS.getValue("WorkOrder_Fields_UDF_DATE1");

var y=$CS.getValue("WorkOrder_Fields_UDF_DATE2");

var z=y-x;

var a=z / (60 * 60 * 1000);

var b=z / (60 * 1000) % 60;

var c=parseInt(a)+" hours"+parseInt(b)+" minutes";

$CS.setValue("WorkOrder_Fields_UDF_CHAR1",c); ( Here Workorder_Fields_UDF_CHAR1 is the custom field which shows the Hours and minutes).

 

The above script if you input two Date and Time values, then the output will display in the below format,

 

 


                  New to ADSelfService Plus?