Set url hash/parameter on button click?

  1. My goal:
    Hello! I’m trying to dynamically set url hash/parameters when clicking on a button. I don’t want to open a new url or app, I’d like to add/modify the hash/params of the current url.
    For instance: mydomain/myapp → mydomain/myapp?tab=1
    Or: → mydomain/myapp#tab=1

  2. Issue:
    I can’t manage to do it

  3. Steps I've taken to troubleshoot:
    I tried several stuff including urlparams.hash.tab = 1 but it doesn’t work

  4. Additional info: (Cloud or Self-hosted, Screenshots)
    Self-hosted, version 3.114

    If you read this far, thanks a lot!
    Cheers

Hi there,

You can define your hash value in a variable component, in my case called “hash”. You set then this as the hash value:

image

In the button event handler, you then dynamically set the variable value:

Cheers

1 Like

not a component but just the variable in the code editor

Alternatively, you can set the params directly with the setUrlParameters utility function!

Hi @Darren
Thanks for your input
Sadly, setUrlParameters doesn’t seem to exist in my version of Retool (which I can’t change btw)
But @nelson_zurcher_operify’s version worked fine for me!
Thanks a lot for your help both of you, and sorry for the late feedback.

1 Like