Refresh after Update record

Love this!

Please yes, I have now multiple clients who have to reload manually after an api call is made! Was there any solution presented for @Jakob ?

Hi there, I have tried using many versions of the example scripts in this thread but can’t get the desired outcome.

I have a list block called projects and then another list called order where the visibility is configured so the order block only shows when the record in the project has a certain status.

I have a one click event to update the status of the project record. So ideally when this happens, the orders block should then show. I can only get this to happen with a manual refresh of the page.

Can you advise please?
Thanks

Hi Jen,

If the block is hidden at first, unfortunately you can’t play with javascript to display it => It’s impossible to play with an element that is not already loaded in the page. Said differently you can’t use a frontend code for something that doesn’t exist (which is normal).

Terminology used in the Softr studio can be misleading. In Softr it says “show” or “hide” something. It’s not exactly true => it loads or it doesn’t load something, which is different.

And only a page refresh (using Javascript) would solve the problem.

This would be the script to use, to be inserted in the page settings => custom code header

<script>
window.addEventListener('block-loaded-projects', () => {
    window.addEventListener('update-record-success-projects', () => {
        setTimeout(() => {
            location.reload();
        }, 500);
    });
});
</script>

Thank you so much for the explanation, I assumed hidden meant it was still on the page so it is great to understand how it’s working.
I’ve tried the code and it works perfectly, thanks again! :slightly_smiling_face:

1 Like

Sorry to come back on this, I am trying to perform a similar action but I am struggling.

On the same page as before, I have a list block (ordersubmit) which has a one click action, which updates an order status (an order is link to a project in the base), then in Airtable I have an automation that when the order status updates this updates the project status.

I then have other blocks on this page which show/hide based on the project status. Therefore I thought if I reload the page when that block is updated this would work.

I have noticed that it does refresh the page but the blocks aren’t showing correctly. Even when I manually refresh the page it doesn’t show, but if I leave it for a minute or so and manually refresh it eventually works.

I assumed this may be due to a delay in the Airtable automation, but this all gets updated straight away and even the project status that shows on the page is correct so I don’t know what is going on.

Any help would be greatly appreciated

Can you try to disable the user caching in the app settings => advanced settings.

Also I strongly advise you to go from Airtable Oauth to personal access token. In order to check if Softr is linked to Airtable through OAuth or through personal access token, go to your workspace => datasource. If there is a message behind your Airtable datasource (something like “switch to personal access token”) = click on it and follow the process (you won’t have to link again your blocks, don’t worry).

After doing all of this, there might be some improvements.

If this is not enough a delay of 2 seconds would need to be added in the script.

Thank you, I have just tried this and unfortunately hasn’t changed anything. Even a manual refresh after approx 1 minute shows the page as it should be, not sure why it is taking so long.

Anything else I can try? Sorry I am a bit lost with this.

You are currently without user caching and using personal access token?

App re-published?

Test must be done after clearing your browser caching + quit and re-enter your browser.

Also please try with the live app.

Having this issue is not normal (updates after 1 minute) so if no change => Softr customer service.

Yes, removed user caching and changed to using the personal access token.
Republished. I always test using the live app as I find the preview a little temperamental.

Thanks for all your help

Hey @artur @Jakob was there ever a solve for reloading page after API call? I’m using the new Call API button and a way to refresh the page after would be very helpful.

1 Like

@acjnas do you know if there is a way? I don’t believe we have a native option still.

Here is what has worked so far:

1 Like

Thanks @matthieu_chateau