Can you have two outputs in one script

Hi

I’m using scriptable to do some javascript within Shortcuts, as far as I know it’s the only way how and to be honest, It’s a lot smoother than trying to drag shortcuts around.

Anyway, I’m using this on the Mac so firstly not sure if this has been reported but you cannot create a bookmark otherwise it freezes so I am creating folders using the shortcuts app.

Secondly, Can you have two outputs in one Script? I am running my script and I return my output, I then use another script to return a second output. I could join these scripts together if I knew how to output both returns?

yes definitely. you can return a json which translates into a dictionary in shortcuts.

const retVal = {
  var1: "value 1",
  var2: "another value"
}
Script.setShortcutOutput(retVal)

Thank you. How would I put each value into a variable so I can use it later?

You mean in Shortcuts? Use the Get Dictionary Value from the script’s output.

Oh wow, thank you. That speeds up the process and make the code and shortcut much easier to read.