Calculated Value of Field is Empty on Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:11 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 09:05 PM
Hello @Ankit Singh4
Try
glidefunction:getHours('sys_created_on').
The other workaround is to create custom field on table that holds current date and time and caluculate tye different using glidefunction:datediff(sys_updated_on, custom_field)
Like explained in the thread below:
please mark the answer as helpful and correct based on Impact!!
Kind Regards,
Ravi Chandra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 10:56 PM
Hello @Ankit Singh4
(function calculatedFieldValue(current) {
var date1 = new GlideDateTime(current.getDisplayValue('sys_created_on'));
var g_hours = date1.getTime();
return g_hours.getHour();// return the calculated value
})(current);
You can use this script.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 07:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 10:08 PM
Hello @Ankit Singh4
If your query got resolved, then Plz mark my response as Accept and close the thread. It will help future readers to reach the post.
Regards,
Samaksh