Jump to content
Jasondm007

JSON Config & File Filters - Refining Results in Alfred 3 vs. 4? [Not bug, but related changes in 4.0.2]

Recommended Posts

Posted (edited)

In Alfred 4, were there changes made to the way the JSON Config utility works with File Filters? I have a workflow, that relies on these elements, that now behaves differently after the upgrade. However, I suspect that the workflow was never configured appropriately in the first place, which is why I have not posted this as a bug.

 

In short, this part of the workflow feeds a variable for a Finder tag/label from the JSON Config utility into a File Filter. It also feeds an argument (for an asterisk *) to pre-populate the File Filter's results in a manner that makes them visible to the user in Alfred's search bar (i.e., for those of us who need a gentle reminder about which files include the tag). Unfortunately, since upgrading to Alfred 4, I am no longer able refine or narrow the File Filter's displayed search results by adding more text to Alfred's search bar. The File Filter just spits out the results for the tag/label and does not respond to any text that is added while the results are displayed, which might otherwise narrow the results.

 

Example w. Config

 

To explain, consider the following example for a tag with the value “Yellow” from Finder.

 

The JSON Config utility includes the following code (where the variable “tag” is defined in earlier stages of the workflow and can take on any value, such as Yellow):

{
  "alfredworkflow" : {
    "arg" : "*",
    "config" : {
      "fields" : [
        {
          "field" : "kMDItemUserTags",
          "split" : false,
          "not" : false,
          "value" : "{var:tag}",
          "words" : true,
        },
      ]
    }
  }
}

 

Next, the JSON Config utility feeds to a File Filter whose settings are essentially blanked out as follows:

 

FF99.thumb.jpg.c5c86b034669a45953ec9185a61468c7.jpg

 

Under both Alfred 3 and 4, when triggered, the Filter spits out results that look something like the following:

 

293965204_Results1.thumb.jpg.4eba51d8927148e16d1fee2cf8a0ac07.jpg

 

Now, say I’m looking for the “Pooled” Excel file in the results from above. In Alfred 3, if I typed “Pooled” in the search bar, it would narrow the results down accordingly. However, now in Alfred 4, the results no longer narrow when adding additional text - as shown in the screenshot below.

 

89870343_Results2.thumb.jpg.2091e6cdcb5914f5e0c07a72d8c6114c.jpg

 

To be clear, since the JSON Config utility doesn’t contain any field-related information and the File Filter is essentially blanked out, I've never understood what fields Alfred 3 used to narrow its search results (though it looked like it was using the title). But it always worked like a charm!!

 

If I had to guess, I’d say that Alfred 4’s new sorting options are impacting it. But, to be fair, I’m not sure that the workflow was ever setup correctly in the first place.

 

Does anyone know how to change the JSON config or the File Filter so that it behaves in the same way that it did in Alfred 3 (i.e., to further narrow its results, as described above)? I tried toying with both elements of the workflow but have not had any luck.

 

For testing purposes, I have created a small workflow that includes the relevant portions described above, and uploaded it here:

 

https://cl.ly/0d64ceb966bc

 

It is not the full workflow - which is specific to my odd Finder tags/labels, and contains a few additional steps. In any case, it should help get the ball rolling if my description above is a little tough to follow.

 

Thanks for any help you can lend!!

Edited by Jasondm007
typos

Share this post


Link to post

@Jasondm007 I'm going to move this into the bugs forum to remind me to look at this in the morning. Quite a bit changed with regards to the file filter object, and I want to make sure I haven't introduced a regression.

 

Cheers,

Andrew

Share this post


Link to post

@Jasondm007 I've taken a quick look at this - you're missing the query field in your fields, so Alfred doesn't know you want to narrow things down.

 

In both Alfred 3 and Alfred 4, your JSON would need to look a bit more like this (note there are normal brackets around the query value to tell Alfred to use the typed {query} instead of the fixed {query} passed into the JSON config😞

{
  "alfredworkflow" : {
    "arg" : "*",
    "config" : {
      "fields" : [
        {
          "not" : false,
          "split" : true,
          "field" : "kMDItemDisplayName",
          "value" : "(query)",
          "words" : true
        },
        {
          "field" : "kMDItemUserTags",
          "split" : false,
          "not" : false,
          "value" : "{var:tag}",
          "words" : true,
        },
      ]
    }
  }
}

It's also worth noting that I'm making a couple of tweaks in Alfred 4.0.2 which will make using {var:} much more robust within the "Fields" prefs directly (this was added as a v4 feature), so you won't need to use the JSON config at all.

 

I'll be getting 4.0.2 in pre-release today.

 

Cheers,

Andrew

Share this post


Link to post

4.0.2 is now in pre-release, so you should be able to reliably use {var:tag} directly in Alfred's Fields prefs instead of needing to configure it in JSON.

Share this post


Link to post

@Andrew Thanks for the clarification on the JSON Config utility! In past attempts to fix the workflow after the upgrade I had mistakenly used the curly brackets {} and not the parentheses () with query, which explains why it didn't work.

 

Also, thanks for the File Filter update in 4.0.2. It works perfectly without the JSON Config utility! It's a million times easier now!!

 

Unrelated to this thread, but thanks for fixing some of the dark mode-related quirks in 4.0.2. It looks great!

 

Thanks again for all of your help, and attention to everything! Honestly, I don't know how people work without Alfred. Hope you have a great weekend!

Share this post


Link to post
Posted (edited)

For those who come across this post in the future, and who are looking to do something similar, I’ve uploaded a new version of the test workflow described above here: https://cl.ly/fe0cb259c299

 

It’s updated to show the two different ways you can accomplish what’s described above. All of the usual caveats apply. Here’s a screenshot of it:

 

workflow.jpg.6b56aedf92a0ceefd5dc73dfe9ba9cab.jpg

 

 

The old approach - shown in yellow above - relies on the JSON Config utility (which now works again, thanks to @Andrew). And the new approach - shown in red above - accomplishes everything through the File Filter itself, and by adding the asterisks * directly to the Arg & Vars utility. It will only work if you're using Alfred 4.0.2 or newer.

 

As for the new approach, here’s a few screenshots of the relevant utilities’ settings:

 

File Filter - New Approach

 

2068737215_filefilter.jpg.088a586977ba6b47004538cacbccb17c.jpg

 

Arg & Vars - New Approach (old approach simply excludes the *)

 

1265973757_argvars.jpg.9b81e57d1dbf7722d982b56d7bd17b7b.jpg

 

Hope this helps!

Edited by Jasondm007
update screenshot w. correct update no.

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