Passing a variable from one action to the next

Hi! I just can't this to work.

I'd like to "Run Real JavaScript" and set a variable in it.
Use that variable in the next action which is "Show Floating WebView"

If anyone has time to help, thank you so much!

what would you use the variable for? (with more details I can probably give a full example)

Hi! Thanks you for answering.

First of all I forgot to mention that this is for Finder.

The "Run Real JavaScript"-action lists all folders in the given folder ("/path/to/the/folder" in the script as an example).

(async () => {

let appleScript = `
		tell application "Finder"
			set folderPath to POSIX file "/path/to/the/folder" as alias
			set folderList to name of every folder of folderPath
		end tell
		return folderList           
`;

let result = await runAppleScript(appleScript);
returnToBTT(result);
})();

I'd need to get that list of folders into the "Show Floating WebView" -action. There the idea is to create buttons from that list.

Easiest would be to run this directly in the floating webview, there is an example for this here:

http://docs.folivora.ai/docs/10_3_webview_scripts.html

Then you would not need to pass it to the webview.

I tried that at first but could not get it to work

Here is a very simple example (done using "Floating Menus"),you just need o adapt the path.

ExampleWebView.bttpreset (13.3 KB)


<html>
<head>
<script>
async function runSomeAppleScript() {

// put the Apple Script into a string (back ticks are great for multi -line strings)
let appleScript = `
  tell application "Finder"
			set folderPath to POSIX file "/Users/" as alias
			set folderList to name of every folder of folderPath
		end tell
		return folderList       
`;

// this will execute the Apple Script and store the result in the result variable.
let result = await runAppleScript({script: appleScript});

//do whatever you want with the result
document.getElementById("result").innerHTML=result;
console.log('result', result);

}
</script>
</head>
<body>
<button id="testButton" onclick="runSomeAppleScript()">Run Apple Script</button>
<pre id="result"></<pre>
</body>
</html>