How to combo multiple Actions with conflicting variable names?

First post.
I’d like to make Action ‘combos’ (multiple Actions strung together, often using Actions that were shared publicly in the gallery) using “Include Action” as an Action Step, however there are variable name overlaps across actions that I’m using, causing an error “can’t create duplicate variable”. (1. Is it a good coding practice for sharing Drafts Actions to unset temporary variables, so they can be strung together?).

2. Is there an easy solution to this? 3. Or do I need to go in and unset+delete the temporary variables at the end of every Action that I want to chain together?
Otherwise, 4. I’d like to request a feature to have either an Action option or Step Type to clear variables between Action Steps.

Not what you are stringing together exactly, but if there is nothing the scripts in those action are doing that require they define their variable in the global scope, you can create a scope by wrapping the script in a closure.

So if you have a script like:

let s = 1;

That let is creating the variable in the global scope. If you wrap that script like the below, the function closure creates a new variable scope, the the let only exists in that scope and will not conflict with other steps:

(function() {
	let s = 1;
}());

Instead of wrapping everything in a function, can’t you just wrap it in braces?

{
  let s = 1;
  // rest of your code
}

My understanding is that braces make a block, and let variables in different blocks don’t conflict.

This seems to be the simplest option available, thank you! This is working for me.

@agiletortoise it’s not ideal to modify every imported action.
Feature request: checkbox option on “Action Step: Import Action” (unchecked by default) to “Run as new scope”, which would wrap the start and the end of the imported action in braces. Many actions in the directory are single steps, which is easy, I’m not sure if this change would be sufficient for multi-step actions.

I’m not sure what your use case is exactly. It not that common to roll together a number of scripted actions from other sources, nor is it that common that they happen to have conflicting variable names. Never heard of this coming up before, so I’m not sure it warrants a somewhat confusing feature.

You could also consider triggering the actions separately rather than using “Include Action” using URL steps or app.queueAction calls in a script - which then runs them each as if they were run when you tap on the action in the list with their own separate context and logging.