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
Quick question, Ken, can one also delete from the notes? This is critical to my method. I'll update the thread with results as soon as I have them. [I've been adding tags at the end of notes, not the beginning- being text that is not very useful for human edits.]
 
Quote:
Originally Posted by a11en View Post
Can one also delete from the notes? This is critical ...
I think this is at the crux of the situation- I use the standard altering of the text Delimiter to search and replace inside the text of the note, then I set the note to the resulting replaced text, or appended or removed text. This "setting" the value of the note is what is killing the metadata which is included inside the note somehow.

Is there a method that would remove and/or replace text within a note without losing metadata information stored within the note (link etc., whatever OmniFocus sets in its library)?

I almost need a "replace" or "remove" text option as you have the insert option. Insert is nice for making notes from scratch, but does no good for altering notes. (I could append all the time, but this would grow the size of the notes each time the user used my function.)

-Allen
 
I did it! I did it!! :) hehehe Ok, update coming sometime tonight- depending on how crazy I am about trying to make this work.

The trick is to search the note for content - if the note has already been tagged, you replace the paragraph of the tag only. This is easily done, and it preserves links etc.!! :) At least, has done so far! So, this works!

I will update my scripts and add an example here. Then, I will likely make a new thread with all scripts I've worked on so far using this method.

Cheers!!! Excited! :)
-Allen
 
Excellent! Congratulations.

I look forward to seeing your results.
__________________
Cheers,

Curt
 
Success!! My old scripts are working with some changes to how I operate with notes.

Here's what I'm going to do due to time and a pile of things stacked up on my desk right now (not in Omnifocus- I need to get back on the wagon)... I'm going to up this one sample script (download link below) and this bit of explanation...

Before, my scripts were attempting to replace the full text of the note. This obviously has a problem, because there's more to a note than just text. (Not to mention it's really rich text, which always appears to be a pain in Applescript.)

This new version of my script attempts to add a paragraph to the end of the note (currently broken - I'm working on this). This last "paragraph" (line really) will then include the meta-tag you wish to add.

It appears I currently can't add a paragraph without some difficulties, so this works best on items that currently have no note. Or, if you add a single line with an & at the end of your note, you can tag the note. [Again, I hope to have this solved soon.]

WARNING- in this version, the last paragraph in your note may end up getting replaced if it happens to include the "&" symbol as the first letter of one of the lines of the note!!! [I need to add another else statement to solve this.]

This script does include sample script text from other sources, which I have not credited here. This is an oversight- if you know the source of the text included, or you are the author, please get in touch.

The point of sharing this is just this- that there is a method to include text strings, i.e., what I'll call "meta data" within notes.

The first few lines of the code can be replaced with the desired list of text items to select and tag selected notes with.

As an example...
Code:
set EnergyLevels to {"High", "Low"}
set FirstDelimiter to "&E"
set SecondDelimiter to "E"
set AddEnergyResponse to (choose from list EnergyLevels with prompt "Mark this task with Energy Level: " OK button name "Mark" without multiple selections allowed and empty selection allowed)
set mySelection to "E" & AddEnergyResponse as text
Can be edited to include things like:
Code:
{"Q1","Q2","Q3","Q4"}
(which is coming BTW), allowing you to create a dialog for tagging tasks with a subitem of a set list you use frequently.

Please note currently this script has a problem for most people with notes already- namely that it won't work unless you have no note, or if the last line of the note includes a single line with & at the beginning.

This is a good start, though.
-Allen

ps- the "insert" command apparently doesn't understand the comment "after" last character, last word, last paragraph etc. So, I can't append to the end of the note. Perhaps I'll have to make my tags at the very first line of a note. :( [should solve the problem, but is not as graceful]

Replace ".applescript" with ".scpt" (I think that's needed...)
Attached Files
File Type: applescript Energy2.applescript (11.5 KB, 472 views)
 
Yeah, if I can't figure out how to append a paragraph ("insert TEXT at after last character" as an example), then I'll just have to rewrite everything to do it at the beginning of the note always. [Not much work to do this, but I'm swamped at the moment.]
 
Quote:
Originally Posted by a11en View Post
Yeah, if I can't figure out how to append a paragraph ("insert TEXT at after last character" as an example), then I'll just have to rewrite everything to do it at the beginning of the note always. [Not much work to do this, but I'm swamped at the moment.]
Looks like inserting after the last [anything] fails due to a scripting bug in OmniFocus. I have a potential fix, but it needs more testing and reviewing before it makes it into the app. (The fix might not make it into 1.7.)
 
Awesome, Ken!

This is fantastic to know how we can add to notes without hurting the links and other information that is under the hood.

I'm going to rewrite my little scripts to make my tags at the beginning of notes (first paragraph insertion) this should work cleanly without a single hitch. Whenever a fix for this happens, I'll just move it towards the end. [By that time, metadata may already be a part of OmniFocus, and this may no longer even be needed.]

I'm really itching to alter the scripts and release my little helper tool, but I have some work commitments I have to keep first. I hope to get this all done by this Monday 8/24 if possible.

I'll also keep replies to a minimum on the thread if possible- everyone must have been sick of getting all those e-mails in their in-box! [Sorry!]

Thank you so very much for your kind reply, Ken, I really appreciate it. Amazed you have the time to check this out! [Thank you!]

My very best as always!
-Allen

ps- My next future update on this thread should be either (1) an example applescript for adding any metadata tag to a tag-line or (2) an updated series of scripts and helper app (or link to a thread including these) [I'll resist additional replies that aren't 1 or 2, unless replying to others.]
 
 


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 03:07 PM.


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