Calculated Value of Field is Empty on Report

Ankit Singh4
Tera Contributor

Hi Experts,

 

I have created one custom field as Integer which stores only the hour of created field. 

Calculate code:

(function calculatedFieldValue(current) {

	var date1 = new GlideDateTime(current.getDisplayValue('sys_created_on'));
    var g_hours = date1.getTime();
    return g_hours.getByFormat('HH');// return the calculated value

})(current);

Above code is giving me required output. Now, the problem is when I use that field in report to show the hours it is giving me empty. And, when I refresh the incidents record it starts reflecting in the list. But, it is only giving me those records which has been refreshed.

Note: Refresh on record here I am doing is, I clicked on list view short description and without updating anything I saved it and it start giving me the records in reports.

 

Please suggest if I need to refresh records to show in reports for calculated field.

 

Thanks,

Ankit Singh
 

14 REPLIES 14

Hi @Samaksh Wani, My issue is not resolved yet. The script which you suggested, I already used it before posting this question here. It is mentioned in my query description, unfortunately it did not help me to find solution for my problem.

 

Regards,

Ankit Singh

can you show me the screenshot what output you are getting

Hi,

 I have attached the screenshot of output.

 

Riya Verma
Kilo Sage
Kilo Sage

Hi @Ankit Singh4 ,

 

Hope you are doing great.

Try using below syntax to fetch hours of date and set in custom field:

 

    current.sys_created_on.getHourOfDay(); // Return the calculated value

 

 
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Thanks @Riya Verma,

 

It is also not fulfilling my requirement.

 

Regards,

Ankit Singh