Way to pre-search list based on url parameter

Sometimes one needs to open a list page with url parameter that upon opening performs a search based on url parameter. The code below helps to achieve exactly that. (It needs to be inserted into page settings custom code area)

<script>
    document.addEventListener("DOMContentLoaded", function() {
        const query = getUrlParam('query');
        if(query) {
            const existCondition = setInterval(function() {
                if ($('div.sw-js-list-container').length || $('div.sw-js-single-item-container').length) {
                    $('.sw-js-list-search-input').val(query);
                    $('.sw-js-list-search-input').keyup();
                    clearInterval(existCondition);
                }
            }, 100);
        }

        function getUrlParam(name) {
            const url = new URL(window.location.href);
            return url.searchParams.get(name);
        }
    });
</script>
1 Like

Can you provide an example URL?

https://your-domain-goes-here/listing-page-with-search?query=findme

pretty much appending → ?query=value

1 Like

Is there anyway to select multiple parameters for one query in the URL?

Hey @dodonerd,

Unfortunately, it is not possible yet. However, we have it in our future plans :slight_smile:

2 Likes

Unfortunately, the code above doesn’t appear to be working within the new studio update

neither does the amended version supplied by @artur shown below

image

Can we look into this?

As this was working well with our cloud phone system opening up contact details via the url

image

I know @artur was looking into this but since the Slack channel has been closed not been able to follow up on messages

@Dan is your page with List or Table block ?

:wave: @artur the page is a list block…

@Dan we are looking into this. It’s a newer version of a block (completely changed internally) we will add the filter options soon and let you know

Ok thanks @artur i really believe if we can get this working properly you should look to promote it… intergrating cloud phone systems with Softr makes sense in so many ways for business portals

Thanks again Dan

@Dan can you pls try this ? https://your-domain-goes-here/listing-page-with-search?search-for=findme

Thanks @artur will give it a try and let you know

1 Like

This code is now working really well @artur and seems much quicker in carrying out a search :+1:

1 Like

Thanks for letting us know @Dan