Jump to content

Can't get a snippet to work in a workflow


Recommended Posts

I have a snippet 'nextsun' defined that produces a YYYYMMDD date, e.g. 20220501.

I would like to combine this with a {query} input term along with a URI ready to use in an x-callback.

But I can't seem to combine these things together.

image.thumb.png.6eaf659ce5d93209dd2131192d577245.png

The URI that is opened is almost correct, but it still includes 

...{snippet:nextsun}...

in the middle of it. 

https://www.alfredapp.com/help/workflows/advanced/placeholders/ says this should work since 4.1, and I'm on the latest release. What am I missing, please?

Link to comment

When asking for help with a Workflow, please upload it somewhere as we can’t properly help you without access to it. Debugging can already be hard with access to the code, and you’re asking us to guess yours from a description and screenshots. There are multiple places where your code or Workflow setup may be going wrong, and without inspecting it we’re shooting in the dark.

 

Also, never say “latest release” but always the exact version. With “latest” we don’t know if you mean the latest pre-release or stable version, nor do we know if you’re really on the newest version. You may think you’re up to date but be mistaken, or might be a version behind because the auto-update hasn’t kicked yet, or we may be on what we think is the latest version but isn’t, or a multitude of other reasons. “Latest” also makes it difficult for people who face the same issue later on and find the conversation, as they’ll have no idea if their version matches the one in the report.

Link to comment

@vitor thanks. Version = 4.6.4.

I've tried many different versions of this workflow, all to no avail. The common factor is what I have distilled out ... the snippet is not getting expanded in the > step.

I've created a simpler non-working-example ... though you'll need to setup a dummy snippet as well, of course.  It should just show a Large Type "{your snippet contents}_{query}".  However, I can't see how to post it here, and pastebin doesn't seem to be an option either.

 

Link to comment

@JGC A more suitable way to add a variable like this is via the Arg/Var object itself. You only need one variable object between your keyword and your Open URL object, with the following content.

 

image.png

 

Snippets weren't designed to be used in this location for a number of reasons, one of which is that the snippet isn't exported with your workflow.

 

I'll update documentation about dynamic placeholders and snippets to make this clearer.

 

Let me know if you need any further help. :)

 

 

 

Link to comment

Thanks Vero ... but this doesn't solve my problem which requires either the snippet expanding, or its equivalent processing. 

The snippet definition is 

```

set theDate to (current date) + 1 * days
repeat until weekday of theDate = Sunday
    set theDate to theDate + 1 * days
end repeat
set theDate to year of theDate & (text -2 thru -1 of ("0" & (month of theDate as integer))) & (text -2 thru -1 of ("0" & (day of theDate as integer))) as string
```

From your experience what's the best way to replicate that in the workflow? :)

Link to comment

Sorry, but I'm still not figuring this out. 

I need both {query} and result of the script I gave above. I can't see how to trigger the AppleScript and still have the {query} passing through to where I need it.

So I've changed to having just AppleScript form the whole URL. 

Now I'm getting 

```

ERROR: Announcement[Run Script] /Users/jonathan/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/9D8F8837-E6B8-4C41-AB82-5D505F841E95:408:412: script error: Can’t set URL to "noteplan://x-callback-url/addText?noteDate=" & theDate & "&mode=append&openNote=no&text=" & argv. Access not allowed. (-10003)

```

I thought I had all the relevant Monterey permissions turned on for Alfred. But perhaps there's another I need for this particular app?

Link to comment
On 5/6/2022 at 5:37 PM, JGC said:

I can't see how to trigger the AppleScript and still have the {query} passing through to where I need it.

 

Either output it with the AppleScript and parse it in the next object, or have an Argument and Variables Utility before to both send the argument and capture it as a variable then use the variable when you need it.

 

On 5/6/2022 at 5:37 PM, JGC said:

I thought I had all the relevant Monterey permissions turned on for Alfred. But perhaps there's another I need for this particular app?

 

No, that doesn’t look like a permissions issue. Instead of argv you probably want something like item 1 of argv.

 

If that doesn't do it, I’ll need access to your most up-to-date version to be able to help further.

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