Creating Function field using glidefunction:datediff()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 06:18 PM
I want to have a column in the list giving how many days back the incident was created without storing it in the database. Therefore, I do not want to create a database column and maintain it all the time. Therefore, I created a Function field on my table.
By doing: using dictionary-> New -> a record with Function Field = Yes
with Function definition as glidefunction:datediff(sys_created_on,now());
Instead of number of days, it is computing 1969-12-31 23-28-34. I guess that there is a mismatch in the format of sys_created and now(). Can someone please suggest what function do I use instead of now().
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2022 07:37 AM
Any one received answer for this? I am facing the same issue as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022 05:29 AM
Thanks to the amazing Gurjot Joshi, needed to create a separate "current date" field on the form itself which had a calculated value on the dictionary entry of:
(function calculatedFieldValue(current) {
// Add your code here
return new GlideDateTime().getDisplayValue()+''; // return the calculated value
})(current);
It shows the current date on this new field. Then, since we wanted to calculate the number of days between today's date and a "vacated date" on the form, used: glidefunction:datediff(u_current_date,u_date_vacated)
Hope this helps as it appears that the "now()" is producing errors even if syntax is correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 08:33 AM