How to 'update' date calculations
Hi folks,
as far as I can see the calculations only happen once when the referenced items are updated.
There something like moment(@My date field).fromNow(); will give a static difference.
Does anyone know how this can be dynamic?
A 'dirty' solution is to update a field in another referenced app every hour through a cron job. This will trigger the calculations to happen again (of course if it is linking itself to all the items you want to update).
@reference variable that changes hourly;
moment(@My date field).fromNow();
Thanks for the help
-
Another again 'dirty' way is to have a cron that updates the javascript formula of the field with for example a timestamp.
So you would get1401378890; moment(@My date field).fromNow();
And one hour later
1401382490; moment(@My date field).fromNow();
Updating the definition of a calculation field triggers podio to recalculate all the fields.
-
Hi Andreas,
I'm not sure if I understand your solution.
- First of all I'm not talking about the code snippet I posted in specific but rather to a solution for a common problem.
- second, if we do look at this specific example, the @my date field does not change over time. So when I use the API to update that field, it will also not trigger the calculation.
So the only way to make sense of what you are saying in my context is to have a dummy variable I put in the calculation that I update when I know that the calculation should be refreshed. For example
@dummy time stamp; // this variable is updated whenever I think the calc needs to be redone moment(@My date field).fromNow();
Ok, let me combine my questions so that we go quickly to a solution.
- is the code snippet I posted what you are after? If not, what then to solve the generic 'update calc' situation
- API wise there is still no way to batch update a big number of records, I would be stuck to 250 items an hour.. (or need to activate the unique ID in the app and do an excel import..) or am I missing an alternative?
- What about the calc definition update, would it be acceptable or not?
Thanks for the answer so far!
-
Hi Pieterjan,
The calculation field is not meant to handle your situation. The field is for making calculations based on input from other fields. Your calculation doesn't do that.
You can trick the field by including a reference to a field that will change often to force re-calculations. This will currently work, but I can't promise it will continue to work. If this is client work for many users I don't think I would rely on that if I were you.
My point was just that you still need to update some field to force the re-calculation. If you are doing that field update via the API you might as well cut the middleman and not use a calculation field at all.
/Andreas
-
Hi again Andreas :), thanks for the quick response!
Everything you mentioned is clear and true, therefore for now I'll keep this mechanism just for myself and understand if it won't work in the future anymore. Also I'm aware that I'm using the calculation field outside of its regular scope. We can and will thus close this forum thread.One last thing: I just like to motivate the reason why I wanted to offer my solution to the broader public. Looking at other forum topics I saw that others are having the same desire to get that extra from the 'time driven' calculation fields.
- days until deadline launch, another one
- days passed since event
- calculate birthday this year
- payment client overdue (taking into account payment_due_on date)
There are other things on the Podio Agenda that are WAY more important than this, so I know this can not be fixed by Podio, but that was thus why I thought of an in between solution.
Have a nice day, and I'll see you in the next Podio topic ;)
-
Hi,
I have to find a solution for the same thing and I just wanted to share my thought
@Andreas:
I see that calculated fields where not meant to be used this way and that we can simply set a normal text/date field via API directly. But "updating" a calculated field has one major advantage: it is readonly! So it is clear for the users, that they are not meant to insert something here. What is your advice on that? I would instead of course love to have "readonly" fields, that are not meant to be edited by users but automatically via API only. Could use this functionality a lot on all kinds of fields text, number, date and even link.
Regards,
Andreas
Please sign in to leave a comment.
Comments
6 comments