How to pass and read parameters from script a to b?

The latest post on this topic seems to be from 2018. If there’s something newer and relevant, please point it out to me.
I want to call Scriptable script from another one, passing along some parameters. So I build an URL like this one

scriptable:///run?scriptName=Test&foo=%5B%7B%22a%22:1,%22b%22:2%7D%5D

The parameter foo is an URI encoded array with one simple object. Now, in Test, I want to work with this parameter. Testing with the URL above in Safari, I get error messages when I use the property queryyParameters of the args object and then JSON parsing the decoded string (unexpected identifier “object”)
What’s the right way to do this?

1 Like

Found the answer: one has to use JSON.parse(args.queryParameters.foo). The queruParameters are an object, one has to access the parameters separately by using their names as properties of queryParameters.

1 Like

Have you tried using importModule to import the other script? That would bypass the need to jump between scripts.

Thanks for the suggestion. What I was trying to do was open an HTML document from a widget. That seems not to be possible at the moment, though - at least not, if the HTML is build on the fly by another script.
Less contrived: display a widget with several lines in it. If the user clicks on one of them, a detailed view is opened. Since clicks in widgets have to target an URL, I thought to use a scriptable:/// one that would then build the HTML and display it in a web view. Which seems not to be possible.