The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Scripting Notes erases links to files etc.? Thread Tools Search this Thread Display Modes
Hi guys,

Just a heads up here- I've been scripting around with notes of items, and it appears my methods are erasing links to files and applications etc., within the note fields. Is there a method to script the note areas without erasing this critical information?

Thanks!!
-Allen
 
A bit more information. Ok, if you try out the following code on a single selected task with meta-data inside (i.e., a link to a file or folder etc.) you will see my trouble...

First, let's look at a note...

Code:
tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
		set selectedItem to value of item 1 of theSelectedItems
		set selectedNote to note of selectedItem as rich text
	end tell
end tell
Now, no matter how you do it, rich text, or normal text, I can't see the links within the note.

Now, if we set the value of the note (let's say we want to add some info into the note, like a url or text etc.) we erase the whole note, because we are not receiving the whole note to work with...

Code:
tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
		set selectedItem to value of item 1 of theSelectedItems
		set selectedNote to note of selectedItem as rich text
		
		set NewNote to selectedNote & " This is a test."
		set note of selectedItem to NewNote
	end tell
end tell
The link disappears as we add our text (or remove text).

Is there a proper way to work with notes so you don't lose this info? Thank you for your help!!!
-Allen
 
Allen,

I haven't worked with this much, but notes have attachments in addition to their text value. I think you need to manipulate all of the note properties to do what you're after. (If what you after is supported at all.)

It looks like you might be pioneering some note scripting things. Good luck, and report back if you have success!
__________________
Cheers,

Curt
 
Oh... ha... ok, I better check that... ach... well, the scripting definitions show the notes as being rich text. They don't mention properties of notes, which would be excellent. Lemmie do some more digging.

BTW, I have had wonderful success with the little I've wanted to do. I didn't want to post it here until I solved the problem of links to files within the notes. The strange thing is that I can't seem to see the attachments at all. However, I did just find the "Attachment" definitions in the scripting dictionary, so perhaps the answer lies there.

Ach, I don't have much time to work on more of this... the simple text only version works wonderfully right now. If I could just solve this one thing...

Here's an image for you... (I may be shooting myself in the foot attaching this... but here goes...)


The "assistant" above is a stand-alone application that launches via applescript, and also feeds selected filter text into the filter box in the frontmost window. [think radio-buttons and filtering based on those buttons]

It's my attempt to leverage some of the smartness of the computer with the large numbers of items I have in my lists.

Now, if only my tagging scripts would work with attachments!!!
 
:( Still having trouble with richtext notes of selected items. Can't seem to get the text of the notes, and not alter the attachments. I thought attachments were a child of the task, and not of the note... but it's clear the attachments are contained within the note- as setting the note text will clear all attachments...
 
It would be wonderful if this would work. Can anyone detail the heirarchy of the notes, and give examples of how to edit them (add and remove text) without losing the meta-links that the database includes to files etc.?

This is the solution to meta-tags, guys. If we can edit notes without screwing up the links, we have our own solution to meta tags, available now before 2.0.

Please Omni, check out this problem of editing notes, and let us know what's going on.
-Allen
 
You should use Help --> Send Feedback to submit feature requests.
__________________
Cheers,

Curt
 
Sorry I didn't see this thread much sooner! The solution is to manipulate the contents of the note directly, rather than trying to make a copy as rich text (which loses attachments).

Here's an example:

Code:
tell application "OmniFocus"
	tell front document
		tell document window 1
			set theSelectedItems to selected trees of content
		end tell
		repeat with selectedItem in theSelectedItems
			tell value of selectedItem
				if note is "" then
					-- Workaround for bug in 1.6 where empty notes ignore edits (fixed in 1.7)
					set note to "Omni web site"
				else
					tell note to insert "Omni web site" & return at before first character
				end if
				tell note to set value of attribute "link" of style of paragraph 1 to "http://www.omnigroup.com/"
			end tell
		end repeat
	end tell
end tell
Hope this helps!
 
Hi Ken-

This is very interesting. I've posted in the Applescript section inquiring about doing this in OmniOutliner. Is it possible, and if so, would you be so kind to post a simple example?

AFAICS, there's no "link" attribute of a style in OO3...

Best, Charles
 
Ken- I'm so sorry I didn't see your reply earlier. I'm going to play with this this weekend and see if I can fix the issues I had earlier. If this solves the problem, you're going to make me one very stoked OmniFocus User!!! :)

I'll post here with any updates with success (if I have it!).

See you soon! [I'm humbled Ken's replied directly here, thank you!]
-Allen
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML links in notes? fmcgeough OmniPlan General 4 2013-01-13 11:17 PM
Links to files - OG seems unique Simon Knight OmniGraffle General 0 2012-01-26 12:09 PM
Creating Links to Files : is there a script? Simon Knight OmniGraffle General 5 2012-01-14 12:18 PM
Links to open external MOV files shanmc OmniGraffle General 3 2011-08-18 11:43 PM
Add files instead of file links as a default robertovalerio OmniFocus 1 for Mac 3 2011-01-18 06:14 AM


All times are GMT -8. The time now is 09:09 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.