The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus 1 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=38)
-   -   Append paragraph to task's note via AppleScript (http://forums.omnigroup.com/showthread.php?t=16810)

waltermundt 2010-07-20 08:10 AM

Append paragraph to task's note via AppleScript
 
I can't seem to figure out how to append a paragraph to an OmniFocus task's existing note in AppleScript without affecting any existing rich content. A couple of online resources suggest something like "copy note & "stuff" to note" but that removes all formatting.

I can set the entire contents of a note with "copy "foo" to note of [task]". I can even replace an existing part of the note that way, e.g. "copy "foo" to last paragraph of note of [task]" works.

However, if I want to add to the end of a note, there's no easy way: "copy "foo" to end of note of [task]" results in "OmniFocus got an error: Can’t set last insertion point of note of [task] to \"foo\"." "copy "foo" to the end of paragraphs of [task]" gives a similar error.

I can "copy [paragraph] to end of note". However, if the note is a single-line note to start with, that doesn't create a new paragraph to change, so it's not very helpful for my purposes.

"insert "foo" at end of note" results in "OmniFocus got an error: Can’t make or move that element into that container."

I also tried duplicating the last character, and then copying some text over that. That almost works, except that the text inserted inherits the styles of the character that was duplicated, and I want the text to have the default styling. Is there any way to clear the formatting of a part of the text?

In summary: Is there a straightforward way to append text to a note without messing up formatting?

waltermundt 2010-07-20 08:29 AM

I'd rather this was simpler, but you can do it like this: (presume you're in a 'tell [task]' block for convenience):[INDENT]copy note's last character to end of note
set note's last character's style to missing value
set note's last character to "\nNew line of text here"
[/INDENT]Of course, if there's no note to begin with, this won't work. However, in that case you can just set the note to whatever you want.


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

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