Exception Reports should also Include Exception Age

Priya madyapgol
Tera Contributor

Hi Team,

I have one requirement on Customer Service Application,

In that i have Exception Table, and we have Exception Reports as well, and now i want to show the age of those Exceptions,
For that i have created one Custom field, i.e, Exception Age (String field), and in the field dictionary calculate section i have written the below script.

 
var datedif = gs.GlideDateTime.subtract((current.sys_created_on.getDisplayValue(),gs.nowDateTime,false));
    return datedif;
 
but which is not working, the age of the record is not populating in the custom field.
 
can anyone please help me with this.

Thanks,
Priya
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Priya madyapgol 

share how did you configure it and where you wrote this script, share screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

J Siva
Tera Sage

Hi @Priya madyapgol 

I'm not sure how you configured that on your end, but I've tried the script below in my PDI, and it's working as expected. Please find it below.

(function calculatedFieldValue(current) {

    // Add your code here
    var created = new GlideDateTime(current.getValue('sys_created_on'));
    var today = new GlideDateTime();
    var dur = GlideDateTime.subtract(created, today); 
    return dur.getDisplayValue();

})(current);

 

JSiva_0-1745386111560.png

Output:

JSiva_1-1745386150175.png

 

Regards,
Siva