Post

3 followers Follow
0
Avatar

Using calculation field for showing the date of when a certain field is updated

Hi all

I am very interested to know if anyone knows a way to use the calculation field to show the latest time, that a field was modified in that post - its only for certain fields not the entire post.

I have seen references to "new Date()", but I am not sure exactly how to use it accurately

Thank you in advance.

Daniel Nielsen

Please sign in to leave a comment.

5 comments

0
Avatar

You can create a calculation field and have globiflow update it every time you change a record.

For example, I have a note app with a date (which is just "created on" date field).

I have another date field which is blank.

On globiflow, I create a flow with a trigger on the description field for the app. When I change something in the description, globiflow automatically updates the date to the current date.

I also have another calculated filed which calculates the number of days between when the record was created and the last updated. This tells me how many days is it been since I last updated this document.

Hope this helps.

Here is the code.

Field name: Days since created

Code : 

var d1 = moment(@Date);
var d2 = moment(@Last updated on);
var result = d2.diff(d1, 'days')+1;
result;
Darius 0 votes
Comment actions Permalink
1
Avatar

Hi Daniel,

in the calculation field enter the tokens for those "certain" fields:

//@field 1 @field 2 @field 3
moment().toDate() 

like in this example

When you create the calculation field it will show current date and time. Each time one of the listed fields is changed it will update date/time to the date/time it was changed. 

An alternative is using Globiflow (as Darius mentioned it): 
Add a date field to the app and build a flow with filters: When item is updated AND [field 1] changed OR [field 2] changed OR [field 3] changed, update item [date field] == Value [current date & time].

Rainer

Rainer Grabowski 1 vote
Comment actions Permalink
0
Avatar

Thank you for your suggestion, Rainer

The problem is however, that this code also records when you edit or change the template for that app. The same goes for some of the similar solutions I have found in the community. 

Is there a way to get around this?

(P.s. I unfortunately do not have Globiflow)

Daniel Nielsen 0 votes
Comment actions Permalink
0
Avatar

Hi Daniel,

When trying your code moment().toDate().

Is "toDate" the actual field name that you are using?

I have created a field name called "Created on" and tried the followings and I get an error:

Created a calculation field with the following values:

Filed name: Created on, value = @Created on (which probably I don't even need)

Last updated on = moment().Created on()  (I get an error)

Last updated on = moment().toDate() 

The calculation field must reference at least one other field. It cannot be entirely based on static data, such as strings or numbers.

Any idea?

Thanks

 

Darius 0 votes
Comment actions Permalink
0
Avatar

Hi Darius

You don't need "new Date()", if you only need the field to show the created date of the post. In that case you only have to add the @Created on -tag in the calculation field.

Daniel Nielsen 0 votes
Comment actions Permalink