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-21-2023 05:07 AM
Hello @Ankit Singh4
Greetings!
due to the nature of Calculated Fields, you cannot report on them. Calculation fields just calculates on the view and they never stores in the server unless the record is saved. you can change it to function field which is more effective.
refer about function field here:
If my response helped please mark it correct and helpful.
Kind Regards,
Ravi Chandra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 05:26 AM
Hi Ravi,
Thanks for your assistance, I already tried function field as my first solution but it gives me time in UTC timezone which gets differ from created on field time zone for which I need to work on display value of created field. For example if we click on total count of record under 4 hour it redirects us on table's list where if we compare the time from report hour and the created time both will be differ due to time zone issue.
Any thought on this.
Thanks,
Ankit Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 09:14 PM
Hello @Ankit Singh4
You can convert the format in the function itself. Could you pls provide the script you used.
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-23-2023 07:48 PM
Hi @Ravi Chandra_K,
I have used below substring in report for functional field to get the hour only. But, it has given me hours in UTC time zone.
glidefunction:substring(sys_created_on,"12","2")
Thanks,
Ankit Singh