Calculations are not triggering item.update
Hi fellow programmers,
I'm caching data locally to save on API calls later on but am bumping into troubles keeping my cached data in sync with the Podio. It's all related to the calculations and webhooks.
Here are my questions and I'm curious what solution Podio or other developers see for it
- when listening for the item.create or item.update hook, I get the item before all the calculations are finished on that item. Is there a way to only get the item with all calculations finished. What solution do you see for this? (waiting a couple of seconds before fetching the item is a kind of an ugly solution)
- when I create/update/delete an item, and this updates an item in another app I do not get an item.update webhook. Is this possible in another way?
- When I update the calculation definition of an app field, in the background podio will update all of the items, but the again, no item.update webhooks are launched.. How to solve?
Thanks for helping me out!
Great questions on calculations and webhooks! To provide a little background, calculations are done asynchronously and continuously when the dependencies of the calculation changes. This means there's currently no clean way to know when all calculations for a particular item update are finished.
Changes to calculation fields does currently not trigger a item.update webhook. I'll take it up with the team whether this would be feasible to do.
Hi Andreas, thanks for the info.
What would already greatly help is to update the 'updated at' attribute of an item when the value of calculation changes (which is currently not the case). In that way at least we can already do a filter on items changed for example in the last day and get recache those items.
You see what I mean?
This could be interesting for others. I found a workaround to have an accurate date of when an Item last changed.
You create a calculation field and mention ALL of the fields (through @ symbols) on a separate line. Then on the last line you put new Date();
@text field 1 @caluclated field 2 new Date()
I won't get into the internals of Podio, but trust me, it works ;)!
The date field will be updated whenever a field (including the calculated fields) changes. Combine this with a Podio::Filter call and you can get all of the items updated in the last day.
Happy developing everybody!
Hi @andreas, Podio Team,
if possible I would like to reopen this thread. From what I've learned over the past few months, I believe that if an async calculation update could trigger an app_field item.update webhook we have a good in-between solution.
- Investment: Not too hard to implement for Podio,
- benefits: Proper, real time caching of Podio items containing calculation fields.
Do you think this could be implemented in the coming months for the async Podio calculations? We would be really really grateful :).
would love to see calculations triggering hooks too.
We see our hooks triggering too often and now wanted to switch to field_level hooks instead. One use case I want to solve: we have address data split into several fields (country, zip, city, street, street2, number). Then we also have a calculated field "adress_full" showing a combinated string of all of them. Actually I want my hook to only fire when the "adress_full" has changed. I tried that, but it never fires (no error on hook creation tough!).
I would not want to have field level hooks for all the single fields - my thought here: when adress data is edited, I do not want to fire on every single field the user edits, but only once when the edit is complete. Due to the async nature of calculations I hoped I could achieve this, so the calculation runs whenever it runs and triggers my hook to do his work.
To me it would also be ok if calculations would not trigger by default, but only if a specific field_level hook asks for the field to trigger.
My trick for handling this situation is to cache the update webhooks in a database table. All i'm trying to save here is that the Item has been updated, not what has changed. So if a user is updating a bunch of fields in a single item I don't add any additional records to my cache table. There is only ever 1 for an item.
I then have a cron job that runs every 10 minutes that looks at the webhook cache table. If there are hooks in there then I run my syncing process by...
- looping through the hooks
- Getting the full Item record from Podio
- Updating my database with the current item's value
this greatly limits my actions.
Now this works for me because I don't need the database to be exactly in sync second to second. The only time that might cause a problem is if a user updates a record and then exports records really quickly through my custom export tool. To get around this I have the export process run the sync process before actually exporting the data.
This has been working well for me.
I had same problem. In order to cache records in database our system is handling item.update hooks, but it is not triggered if Calculation field is updated.
I've solved it by adding Podio Workflow to the app. Add date field "Updated at" to the app, and create Podio Workflow to handle change in needed calculation field. When this field is updated fill in Updated at to current date, and item.update ihook s triggered as well then.
Please sign in to leave a comment.