Jump to content

Script Filter output other than "items"?


Recommended Posts

New here, loving Alfred :)

 

So I wrote my first script filter and it works. The possibilities are indeed immense!

 

My script just outputs "items" as the top level entry in JSON. But an example suggested that I could also output variables. Where can I read about all possible output keys?

 

Relatedly, if the next item in the workflow is a script, I believe that it gets the "arg" of the selected item. Is there any way to access the title, the variables in the previous section, and so forth?

 

Finally, what is the lifetime of these variables? (i.e., What if the same script in the same workflow runs again?). My prior experience is with Keyboard Maestro, which has global variables that seemingly live forever. (Oh, and does alfred have long-lived variables?)

 

Many thanks!

  Abhijit

Link to comment

Hi @amahabal, welcome to the forum.

 

I'm moving this thread to the "Workflow Help & Questions" forum, which is where it belongs. You'll also find the answers to a lot of your variable questions in a sticky thread there:

 

 

10 hours ago, amahabal said:

Where can I read about all possible output keys?

 

In Alfred Preferences, look at the sample workflows, specifically + > Getting Started > Script Filter. See also the documentation.

 

10 hours ago, amahabal said:

Is there any way to access the title, the variables in the previous section, and so forth?

 

The variables, of course. That’s what they’re for. Any fields other than arg and variables are not available to downstream elements. If you want access to the title, you’ll need to set a corresponding variable.

 

10 hours ago, amahabal said:

Finally, what is the lifetime of these variables?

 

They work the same as environment variables, basically. They are available downstream until the workflow finishes executing. Once it stops running, the variables go away.

 

10 hours ago, amahabal said:

What if the same script in the same workflow runs again?

 

Sometimes. If the workflow runs itself again via an External Trigger, you can choose to also pass arg and/or variables. Also, top-level variables are passed back to a Script Filter if you set rerun. See the above-linked guide to variables.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...