Jump to content
amahabal

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

Share this post


Link to post

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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...