So in OmniFocus, I can give a URL a title by right-clicking on the URL and selecting “Edit Link…”. That is way cool.
What I am curious about is, how do I do that using the JavaScript automation environment? I even tried this, on a lark…
newTask = new Task(title, enclosingTask.beginning);
newTask.note = “<a href=” + url + “>” + urlTitle + “</a>”;
Is there any magic for this?
Setting the value of “link” attribute seems to work here:
newTask.note.style.attributes['link'].value = url
For example, changing title and URL of note property of the first selected task:
(() => {
'use strict';
// main :: IO ()
const main = () => {
const
appOF = Application('OmniFocus'),
win = appOF.defaultDocument.documentWindows[0],
seln = win.content.selectedTrees()[0].value();
const setTaskNoteAndLink = oTask => strTitle => strURL => {
// Sets "link" attribute and note property
// of a given task.
return (
oTask.note = strTitle,
oTask.note.style.attributes["link"].value = strURL,
oTask
)
};
return setTaskNoteAndLink(seln)(
'OmniGroup Website'
)('https://www.omnigroup.com/omnifocus/ios/')
};
// MAIN ----------------------------------------------------------------
return main();
})();
2 Likes
Whoa, I am so gonna try that! I think I get the basic idea now…this is a text attribute, and I need to set things that way. Thank you Gabriel! Your reply was extremely helpful!
1 Like
You’re very welcome, Richard.