sballin / alfred-search-notes-app

Use Alfred to quickly open notes in iCloud/Apple Notes.
https://www.alfredforum.com/topic/11716-search-appleicloud-notes/
MIT License
510 stars 24 forks source link

Copy notes:// URL doesn't work #29

Closed NeighNeighNeigh closed 3 years ago

NeighNeighNeigh commented 3 years ago

Using the copy note as URL feature throws error

Here is the debug log output

[18:15:33.998] Search Notes[Script Filter] Queuing argument ''
[18:15:34.091] Search Notes[Script Filter] Script with argv '' finished
[18:15:34.094] Search Notes[Script Filter] {
    "items": [
        {
            "title": "Scratchpad",
            "subtitle": "Notes",
            "arg": "x-coredata://E56025F2-FC6A-42A7-8A73-EC73F575F9EF/ICNote/p3007?",
            "quicklookurl": null
        }

Deleted a bunch of these for privacy

    ]
}
[18:15:40.844] Search Notes[Script Filter] Processing complete
[18:15:40.845] Search Notes[Script Filter] Passing output 'x-coredata://E56025F2-FC6A-42A7-8A73-EC73F575F9EF/ICNote/p3007?' to Run NSAppleScript
[18:15:40.867] ERROR: Search Notes[Run NSAppleScript] {
    NSAppleScriptErrorAppName = Notes;
    NSAppleScriptErrorBriefMessage = "AppleEvent handler failed.";
    NSAppleScriptErrorMessage = "Notes got an error: AppleEvent handler failed.";
    NSAppleScriptErrorNumber = "-10000";
    NSAppleScriptErrorRange = "NSRange: {392, 4}";
}
[18:15:40.869] Search Notes[Run NSAppleScript] Processing complete
[18:15:40.869] Search Notes[Run NSAppleScript] Passing output '' to Run Script 

To Reproduce Steps to reproduce the behavior:

  1. Invoke Alfred
  2. Type n (followed by a space)
  3. ⌥ Return
  4. Doesn't copy url to clipboard as expected, throws error.

Desktop (please complete the following information):

sballin commented 3 years ago

Thanks for the report. I can't reproduce this... Can you verify that Alfred has permissions enabled in System Preferences > Security & Privacy > Privacy > Accessibility, Full Disk Access, Files and Folders, and Automation (for which there should be an "Alfred 4 > Notes" checkbox)?

If that doesn't fix it, what is your system language? Does this happen when you try to get the URL for a particular note, or any one of them?

NeighNeighNeigh commented 3 years ago

Hi thanks for getting back to me. Alfred has permissions in all those places. My system language is English (Australia). And the problem occurs with all notes. I should mention the rest of the workflow functions and if I manually create a notes:// link, the Note Opener app works as expected.

sballin commented 3 years ago

Hmm, that's weird. You could try copying it into Script Editor.app and seeing where it goes wrong. If you need some guidance, I would start with trying just this to see if it works:

use framework "Foundation"
use scripting additions -- fixes errors due to previous line
property NSString : a reference to current application's NSString
property NSCharacterSet : a reference to current application's NSCharacterSet

tell application "Notes"
    set q to "x-coredata://E56025F2-FC6A-42A7-8A73-EC73F575F9EF/ICNote/p3007?"
    set q to text 1 thru ((offset of "?" in q) - 1) of q
end tell

then keep adding lines before end tell and see where the error happens.

NeighNeighNeigh commented 3 years ago
Screen Shot 2020-08-19 at 1 52 38 am

Seems that error crops up immediately :(

Screen Shot 2020-08-19 at 1 53 23 am
sballin commented 3 years ago

Can you try restarting? And if that doesn't fix it, try unchecking and rechecking the permission checkboxes.

NeighNeighNeigh commented 3 years ago

Im so sorry to report that neither has made a difference. Unfortunately for now I have to go to bed (its 2:33am here lol)

sballin commented 3 years ago

Oh, I think we encountered this issue before! Try changing the line to

set noteName to name of note id q in default account
NeighNeighNeigh commented 3 years ago

Hey that fixed it, thanks. It's so nice to have note linking functionality 💛