Jump to content

Variables Help


Recommended Posts

Posted

I'm building a workflow and could use some help with storing semi-permanent variables.

 

For example, the majority of the workflow will be triggered by the word "app", which asks for a variable of the name of the app the person's working with.

 

I want to store that in a variable that I can use in a different flow within the same workflow, using a different trigger.

 

So my workflow would be:

app {query} → do some stuff → ask a question → store that in a variable.

 

Then, if someone uses input trigger "diagnose", I want to execute a script using the very first variable from the "app" trigger (which could have been an hour or days ago). 

 

If the user triggers the "app" again, I want the variable value to be overwritten.

 

I'm -- right now -- using the Utility of "Args & Vars" which works if the variable is within the main flow, but not if I try to trigger any of my inputs that comes after the initial "app" trigger.

 

I couldn't find a good doc on how to accomplish this (if it's possible). Can someone point me in the right direction?

 

Posted

Variables are forgotten when a workflow stops running. Either save the variable to a file or to the workflow's settings using AppleScript (tell application "Alfred 3" to set configuration...).

Posted

So if I use:

tell application "Alfred 3" to set configuration "APP_NAME" to value "{query}"

As a Run Script (usr/bin/osascript (AS))action after my initial "app" trigger, that'll store my value as a configuration, right?

 

How do I then grab it in something else such as a "Run Terminal Script" action?

Posted
2 minutes ago, mikejandreau said:

As a Run Script (usr/bin/osascript (AS))action after my initial "app" trigger, that'll store my value as a configuration, right?

 

You'll need to add the bundle ID to the AppleScript command, AFAIK, but otherwise it looks about right, yeah.

 

3 minutes ago, mikejandreau said:

How do I then grab it in something else such as a "Run Terminal Script" action?

 

Same as other workflow variables: via the environment.

 

Here's the main article on workflow variables. The original version and comments are stickied at the top of this forum.

Posted

Color me a noob, I'm just not getting it. I'm doing what I _think_ should be working, but it's not.

 

Here's what I'm doing:

app-trigger.png - this is what triggers when someone types "app" and inputs their app name, this should set the configuration value for APP_NAME to the {query}

test.png is the mini separate trigger I wrote to test it. All it does it grab the value from the config and push it to a Notification

get_app_name.png should grab the name from the config and set it as a variable

notification_with_name.png should push a notification with the value the AppleScript grabbed and set as a variable.

 

I'm clearly missing something, but don't know what.

 

Thanks for your help (and patience!)

app-trigger.png

test.png

notification_with_name.png

get_app_name.png

Posted

I figured it out.

 

I don't actually need the AppleScript to get the Variable, since I'm using that variable directly in scripts in the Workflow and not external scripts.

 

Thanks for the help!

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...