The CreatorCon Call for Content is officially open! Get started here.

Creating Function field using glidefunction:datediff()

Rakesh Goel
Kilo Expert

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.

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Rakesh,

So you have created a field of type Function?

Can you share screenshot?

Regards
Ankur

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

Rakesh Goel
Kilo Expert

Ankur,

You are right. Here is the screen shot:

find_real_file.pngfind_real_file.png

Hi,

so for that string field you need to store default value as difference between now and created time?

Regards
Ankur

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

Rakesh Goel
Kilo Expert

Thanks folks, I figured out:

 

1) The Type should have been equal to Duration instead of String.

2) The now() attribute should be first as it is Now minus sys_created_on.

glidefunction:datediff(now(),sys_created_on);

 

Thanks for your help.