rounak Posted September 2, 2016 Share Posted September 2, 2016 Short version: I have dropped a csv file in the List Filter. How to auto-update(without manuallly dropping the csv file again) it? Long version: 1. I have populated the List Filter with Customer names which were exported from a Filemaker table and then re-formatted to match Alfred's [title,subtitle,arg] syntax. 2. New customers will be added in the Filemaker table. The List Filter needs to be updated with those names. Link to comment
deanishe Posted September 2, 2016 Share Posted September 2, 2016 List Filters are static. You have to update them by hand. It is technically possible to do programatically, but that's far more complicated than using a Script Filter, which is the dynamic version of a List Filter. Link to comment
rounak Posted September 2, 2016 Author Share Posted September 2, 2016 It is technically possible to do programatically, Do you mean: editing the info.plist file entry where all the values are stored in the [title,subtitle,arg] format? Link to comment
deanishe Posted September 2, 2016 Share Posted September 2, 2016 Yes. Except the data are stored as JSON. It's easier to send the JSON straight to Alfred than to add it to info.plist. Link to comment
rounak Posted September 2, 2016 Author Share Posted September 2, 2016 Thanks for the help. Since you confirmed that I must edit the plist, I found a way to change the relevant entry. This is what it looks like: tell application "System Events" set plistFile to property list file "/Users/<myusername>/Sync/Alfred.alfredpreferences/workflows/user.workflow.A729E97A-5F14-41EF-9F29-77CEFDAB65BC/info.plist" set itemNodes to value of item 1 of property list items of property list item 1 of property list item 3 of property list item "objects" of plistFile set newentry to "{\"title\":\"NewName (Place)\",\"arg\":\"NewName (Place)\",\"subtitle\":\"\"}" set newString to my str_replace("]", "," & newentry & "]", itemNodes) set itemNodes to newString set value of item 1 of property list items of property list item 1 of property list item 3 of property list item "objects" of plistFile to itemNodes end tell on str_replace(find, replace, subject) ... end str_replace Now, I will create a workflow "Update Customers" which shall get names from Filemaker and update the plist. Link to comment
deanishe Posted September 2, 2016 Share Posted September 2, 2016 (edited) This really isn't the right way to do it. You should use a Script Filter instead. That's what they're designed for. Instead of editing info.plist, save the JSON data to a file and set your Script Filter script to: cat /path/to/json_data.jsonCan Filemaker export an Excel file? If so, you could use this workflow to display the contents of the Excel file in Alfred. It automatically picks up changes to the Excel file. Edited September 2, 2016 by deanishe rounak 1 Link to comment
rounak Posted September 3, 2016 Author Share Posted September 3, 2016 (edited) 0. Demo works correctly. 1. Duplicated workflow 2. Changed bundle id 3. Replaced demo.xlsx with my .xlsx 4. Changed environemnt variable DOC_PATH 5. Changed keyword to isyn x 6. Open Alfred and typed isyn x 7. Fatal Error in workflow: array index out of range 8. All code in python, I can't do anything but post here:) The other alternative of using json file. I have got that to work. Edited September 3, 2016 by rounak Link to comment
deanishe Posted September 3, 2016 Share Posted September 3, 2016 (edited) If yours works, then fine. There is a latent bug in the JSON generation, however, and it will explode if, say, a backslash or double quote pops up in one of your values (because you aren't escaping the strings before you add them to your JSON, as best as I can tell).WRT the workflow I linked to, there was a bug that required there to be three columns. Fixed now. Redownload (version 0.1.1) and set SUBTITLE_COL and VALUE_COL to 0 (zero) in the config sheet.There's no need to duplicate the workflow yourself: You can use the keyword isyn to search for and choose an Excel file. There's no need to put your excel file in the workflow (that's kind of the point). The workflow will notice whenever the file changes. I'm afraid I haven't documented the workflow properly yet. You can download and watch the demo here (it's too big to view on GitHub).You can also read the program's built-in help by running the isyn program in the workflow directory in your terminal with ./isyn -h Edited September 3, 2016 by deanishe rounak 1 Link to comment
deanishe Posted September 3, 2016 Share Posted September 3, 2016 I found a JSON library for AppleScript. That would ensure your script handles all input correctly (if you think that might be an issue). rounak 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now