How to 'update' date calculations

Comments

6 comments

  • Pieterjan M.

    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 get

    1401378890;
    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.

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    Hi Pieterjan,

    If you are already using the API to update field values there's no need for you to use a calculation field. Simply write the appropriate date to a date field.

    /Andreas

    0
    Comment actions Permalink
  • Pieterjan M.

    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.

    1. is the code snippet I posted what you are after? If not, what then to solve the generic 'update calc' situation
    2. 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?
    3. What about the calc definition update, would it be acceptable or not?

    Thanks for the answer so far!

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    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

    0
    Comment actions Permalink
  • Pieterjan M.

    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.

    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 ;)

    0
    Comment actions Permalink
  • Andreas Forstinger

    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

    2
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk