Jump to content
mikejandreau

Variables Help

Recommended Posts

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?

 

Share this post


Link to post

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

Share this post


Link to post

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?

Share this post


Link to post
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.

Share this post


Link to post

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

Share this post


Link to post

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!

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