This is with OmniFocus 4.8.10 (v185.14.0)
This functionality used to work for me, but now it’s not (not sure if it started when I installed this version, but I just noticed it today).
Here’s a minimal reproduction that one could enter at the Automation Console prompt:
(() => {
const t = flattenedTasks.find(x => x.noteText);
if (!t) return "no task with noteText";
const nt = t.noteText;
const originalNote = nt.string;
try {
nt.string = "test marker ❮❮Dagny❯❯";
const r = nt.find("Dagny", null, null);
if (!r) return "find returned null";
const s = nt.styleForRange(r);
const u = URL.fromString("https://example.com/test");
console.log("u=", u, "instanceof URL=", u instanceof URL);
s.set(Style.Attribute.Link, u);
return "SUCCESS — link applied; task: " + t.name;
} catch (e) {
return "FAIL: " + String(e);
} finally {
nt.string = originalNote;
}
})()
If you do try this, it should be non-destructive, but no guarantees.
What it does is find a task in your db that has note text. It then replaces the note text with some sample text, finds a substring, and tries to apply a link to that substring. It then restores the original text at the end, regardless of success.
When I run this, I get
u= [object URL: https://example.com/test\\] instanceof URL= true
“FAIL: Error: The attribute “link” requires values of type URL, but got an instance of _omnijs_AnonymousProxy” = $1
The first line shows that u is a URL, but then s.set complains that it isn’t.
Am I doing this the wrong way or did something break in the latest release?