But what would greatly help me here is to know why you need to do that ?
And why do you need the page to be refreshed afterward ? Does the data change or do you need to displaying a view totally different ?
PS: I see you are still on our legacy agent, I strongly suggest you to migrate to our new agent-nodejs which is more performant, easier to use an have much more feature
We have a corner case where we need one of our database records updated and we need to make sure that, when we load, we are checking the case and updating as necessary. We’re building an endpoint on one our other services to handle all of the logic. The endpoint will check to see if the record needs to be updated, if so update it, and return appropriate status. We’ll need a page (or individual collection, preferably) reload once updated. It’s a collection that is loaded as connected data in a number of our collections so it would be ideal if the endpoint trigger/reload were connected to the collection updated.
We’ve looked into migrating in the past but we a bit apprehensive about the amount of work required as we’re using a number of internal services and I was given the impression that much of our backend would need to be rewritten.
Okey so there is a feature in beta that could help you. You can send notification to the frontend and let the frontend refresh data automatically or display a notification
Looks easy enough. We can just execute the external fetch first in sendNotification, correct?
Does this require the new agent? It seems like it could be independent of agent version.
Where does this need to live for it to execute automatically when the collection loads initially? The only automatic behavior I’m aware of on load of a collection is the smart field get hook. Is that the suggested approach?
Can refresh accept an array of collections to refresh? We may be updating two collections (I haven’t seen final logic on that yet).
How does target work? If we leave it undefined, will it automatically target everyone?
Can you also refresh my memory on recordIds? Is that assigned by FA or is that the id from our db record?
It’s just a webhook, so you can call it whatever the agent you are using.
About the options:
target: If left empty, it will send the notification to everyone .
refresh: It accepts a single collection. If you need to refresh multiple collection, you will need to call the webhook multiple times
recordIds: If you omit it, it will refresh all the records of that collection displayed. The ids are the one you have in your Database
Where does this need to live for it to execute automatically when the collection loads initially? The only automatic behavior I’m aware of on load of a collection is the smart field get hook. Is that the suggested approach?
Isn’t the update done by another App ? If so, just call the webhook when the update is done.
If your issue is that you need to update the record in db when fetching the collection, then just override/extend the route of the collection.
Ok. Thanks! I guess I’m a little confused about what the notification is, exactly. I had imagined that it was just a modal or something that appeared when triggered but if its a webhook, how is the notification delivered? Email? Or will all active users see it? Or?
Extension of the route is a great idea. Again, what I’m trying to do is, when a specific collection loads, trigger an external endpoint, then, if we get a 200, refresh the updated records. If 204, do nothing (success but update wasn’t necessary). If error, alert error.
Based upon what I’m understanding, I’m thinking that the most beneficial would be to extend the get route to hit the external endpoint, process the response and trigger a “notification” which causes the changed records to refresh but doesn’t alert anyone. Does that make sense?
Yes you are right this is what should be done I guess
It won’t alert anyone if you don’t specify the message part (it will just refresh the collection). If you need to warn your users you can just fill the message part to let them know for example that their data has been refreshed