Redirect after action button appending value was executed

Is there any way to start a redirect after an action button has been clicked and the “append value” action has run?

I think this should work (append value being an update action)

<script>
window.addEventListener('block-loaded-BlockID1', () => {
  window.addEventListener('update-record-success-BlockID1', () => {
    window.location.href = 'https://yourdomain.com/path';
  });
});
</script>

BlockID1 being the block where the append value action occurs (to be changed by the correct block ID/Name).

To be placed in the header custom code of the page

1 Like

That’s not really possible, is it?
I don’t see a way of adding a second action on the same action button.

I can only create a second action button with a redirect, which the user needs to click as well to then be redirected?

Am I blind and not seeing this option in Softr?

Oh, that is great @matthieu_chateau !
I would just need to redirect to a dynamic link that is different for each details page. Is that possible? The link is stored in the record, so I guess I can somehow pull that from the current record and dynamically add it in the code?

That would be such a gamechanger!!

This is possible though way more difficult :sweat_smile:.
There are some technical / UX problems. In order to do this you would need to use const onRecords = (e) => { . Problem = the link needs to appear, visually, in order to make it work.

PS: the other answer is a spammer that gives wrong advice and is clearly not a softr user

Does the appen value action occur in a table block or a list-details block?

On a list-details block.

:laughing: this bot lifted my hope there for a second and then crushed it.
The link needs to appear visually = it needs to be on the page somewhere?

Yep. A list-details might be simpler (As I may have no need for const onRecords)
I will try to do something within the end of the week.

1 Like

That would really be incredible!!
Thank you so much!!!

Here is the code to be inserted in the header custom code of the page.
I assume the page is a list details page and always has the recordId in the url parameters.

<script>
window.addEventListener('block-loaded-list-details1', () => {
    window.addEventListener('update-record-success-list-details1', () => {
        const recordId = getUrlParam('recordId');
        if (window.records && window.records[recordId] && window.records[recordId].record.fields['Project_Url']) {
            const redirectionURL = window.records[recordId].record.fields['Project_Url'];
            window.location.href = redirectionURL;
        }
    });
});

function getUrlParam(param) {
    const urlParams = new URLSearchParams(window.location.search);
    return urlParams.get(param);
}
</script>

Change list-details1 by your list-details ID each time you see it.
Change Project_Url by the field where the url is in your table in Airtable (The field name is case sensitive).

No need to have the redirection url field visible in your list-details (for the use case of list-details only)

2 Likes

You are a hero!! I just got away from the laptop but I’ll try this first thing this weekend :pray:t3::pray:t3::pray:t3:

A million thanks!!

1 Like

Hmm, I just tried it, and somehow it doesn’t work - nothing happens after the button has been clicked. :thinking:

After the append_value action, the list-details1 block reloads, so maybe that is the problem?

Trying to ChatGPT my way through how to check that the event listener names are correct etc., but not getting to the bottom of it. I made sure the field names are correct and the list-details ID.

Any ideas what could be the issue?

I added console.logs and am getting this:

Somehow it seems the recordId doesn’t get defined correctly.

I tried with the update action = works. With append value => it doesn’t work.
So it means that append value action doesn’t match the update event listenner. So you will have to wait for this event listenner to be created by Softr. The one-click remove value should come within 3 weeks to 1 month. The event listenner might come at this moment (if it comes). Let’s see in one month.

My test was made with an update action, thinking it might be the same.

Actually it should work, if you have the update record triggered. I get the same result in my console.
The best is you to reach out to the customer support in the Softr studio about it.

With “update action” you mean ‘Edit Record’ or ‘One-click-update’ - ‘replace existing value with’?

Then at least I could already build a first version where I store the value in a placeholder and then append it via an Airtable formula. Would at least be a first workaround.

There must have been a hidden update. It works if you show the Url you want to redirect to in the list details. It must be a field in your list details.

1 Like

What you can do is to display the url but make it invisible by choosing the same color text as the background.

1 Like

With that exact code it works for you?
It doesn’t seem to work for me, example:

Aah, you can’t see the button unless logged in, so you won’t see it now.