I have a scene with a table in it and a form and a details view...
To access the count value I added a details view with that value on it, but using css I set the visibility: hidden, so that I can access the value.. So far so good..
However, when I delete a record from the table, the details view does NOT get updated. So it ends up with the incorrect value for the count.. The record has the correct count, but the view does not.
Any thoughts on how to either get around this, or to do this better?
What I'm attempting from a logical perspective is as follows:
I have a table of lawyers.
I have an input form below it, that has a set of categories, the total of all of them has to add up to the total records in the lawyers table.
I am encountering this issue also (4 years after this post). I am writing custom code to do cascading deletions of records but if the counts are not correct what is the point in having them?
@JuliaGlowa31189 I would need to know more about your specific use case with cascading deletions, but it’s very possible the details view just needs to be re-rendered (stale data/state) when an action is triggered via the table view on the same page.
// replace view_x with your view_key but this is the method for re-rendering views Knack.views["view_x"].model.fetch();
My guess is that the state is not automatically refreshing for all views on the same page when you perform actions like inline triggers/edits. You should be able to use the call above, though, in any use case where you’re listening for a specific UI action on that page.
The actual issue is not with the view, it’s with the count in the parent record. I’ve looked at the records in the builder (refreshed several times) and the error is actually in the database.
I have a parent object called 'Delivery Orders. I have a child object called ‘DO Status Log’. In the parent object there is a count field to show how many DO Status Log records are tied to it.
For one of the Delivery Order records, the count field says that there is 1 DO status log tied to it when in fact there is not. It was recently deleted in a previous run of the cascading deletion function but the count never refreshed. It’s been several hours since the child record was deleted and the count is still incorrect.
I see. I won’t pretend to have an answer to a Knack codebase I’m not familiar with, but when you manually update a value in that parent record from the Knack Builder, does the count field update or no?
If it does, you might try adding a “PUT” request to update a field in the parent record (doesn’t matter which one) after the cascading deletes go through, which might trigger a recount on the database end.
Otherwise, I can tell you I’ve reached out on behalf of clients in the past and Knack has simply needed a record sync. You could request this and ask if there is a way to programmatically issue a record sync from the Knack API (they will almost certainly have better suggestions than me).
Sorry if I wasn’t of any help, but thought I’d check!
Thanks for the input. I updated the parent record which did not ‘correct’ the count. So then I moved on to manually creating a child record using the builder. The count did not change. It remained at 1. Then I deleted the newly created child record and now the count is finally correct at zero. Clearly an issue with Knack. The counter is maintained by Knack and I am not aware of a way to fix this issue. It looks like I’m going to have to ignore the counter and just do a GET call to determine if there are any child records to delete.