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 Syncing > iCal Sync
FAQ Members List Calendar Search Today's Posts Mark Forums Read

sync to iCal as events for due dates? Thread Tools Search this Thread Display Modes
Thanks, dmcg -- your script seems to do the trick! Because I don't care about due times on my actions, I just removed the -if- statements about time and set all actions to all-day events. The new calendar in iCal gives me a quick way to see when my due actions are stacking up. Thanks again!
Originally Posted by dmcg View Post
Sorry to jump on this thread late, but I've had the following script running every hour for while now and it does a good job of giving me iCal events for OF tasks with due dates, and hence iPhone reminders. It differs from the others that I've seen by putting all tasks with a due date into a dedicated calendar (OF-Reminders, which you'll have to create before you run the script).
Brilliant! The only change I made was to make the events allDay regardless.

I tried the other script but it kept giving me errors (one about contexts, another about unable to convert to utf)

Thanks much dmcg!

Last edited by cameronconner; 2009-12-07 at 01:51 AM.. Reason: tired- stupid errors.
I have not gotten into code. Thats why I have to buy my software. But I would like it if OF was a bit more communcative with Ical. It would help.
Hello dmcg,

thanks for your script. It works very fine. I have only one question. What do I have to do for viewing the events in ical with start and end/due time.

Sorry, I don't understand the question.
Brian - Is it possible to modify this script to pull any tasks from Omnifocus with a particular context (say iCal) and add them as events in iCal?

For example, it would be great to retain the existing code (e.g., if highlighted), remove the function that resorts to flagged items (if nothing is highlighted) with one that instead searches for a particular context (e.g., iCal), and then adds them to iCal.

I'm not particularly good with this stuff, so any advice you may have would be most appreciated! Thanks for your help!!


Originally Posted by Brian View Post
Okay, it was pretty trivial to modify the script to create an event for each action instead of a To Do. Just like the other script, if you have one or more actions selected, they get added to iCal. If you have no actions selected, it adds all flagged items.

Creates an event that matches the start and end dates if both exist, otherwise makes a 15-minute event at whichever of the two does. If one of the events has no start or end date, it stops and tells you there's a problem.

Just like the other script, you need to open it up in Script Editor once to make a couple of settings - whether there's an alarm, how long before the event the alarm fires, etc.

Thanks, of course to uku, snarke, and yeary, who wrote the 99% of the code I just ended up copy-and-pasting. :-)
Jason, here's a modification of part of Brian's script that should grab the items in your specified context if nothing is selected, instead of grabbing the flagged items. You'll need to replace the matching section of the original; I've put in a line or two of the original on each end.

property defaultTriggerInterval : -1440 -- interval between alarm and due date in minutes ("minus 1440" is 24 hours before due date)
property contextIfNoSelection : "Office" -- use tasks from this context if launched with nothing selected

set collectedTaskInfo to {}

--Step 1: collect highlighted items from OmniFocus, or flagged items if nothing is highlighted

tell application "OmniFocus"
	-- "window 1" is usually the frontmost window
	set theDoc to document window 1 of default document
	-- collect all the highlighted tasks in that window
	set TaskList to the value of the selected tree of the content of theDoc
	if (count of TaskList) is 0 then -- no items are selected, so let's get all the flagged ones
		tell default document
			set contextMatches to complete contextIfNoSelection as context maximum matches 1
			if ((count of contextMatches) > 0) then
				set contextId to id of first item of contextMatches
				set currentContext to context id contextId
				set TaskList to TaskList & (tasks of currentContext where blocked is false and flagged is true and completed is false)
				display alert "Nothing selected and could not match context " & contextIfNoSelection
				return -- give up
			end if
		end tell
	end if
	repeat with theSelectedTask in TaskList
I'm skeptical about the ultimate value of this modification, as it's going to complain (and quit) if you have any actions in that context which don't have at least one date assigned. Putting dates on everything isn't a great practice, in my opinion, but if it works for you...

Thanks a ton for the quick reply and for the code above.

I inserted the snippet of code above, but didn't have any luck. I probably didn't explain myself very well.

To be honest, I'm not sure if this method really follows the GTD core. I really just like coming in during the morning and taking a quick look at my calendar for specific meetings or presentations that I have to attend, before I get running with my day. In other words, I really don't rely on it throughout the day, it's just helpful when planning things out (w/ Omnifocus, etc). That's why I don't like Omnifocus's default (adding them as tasks).

I've created a context actually called "iCal" for these types of events that I would just like pushed to my calendar as events (while remaining in Omnifocus).

I was hoping to use the existing script - which first looks to see if anything is highlighted and adds it as an event - to replace the second part of the script - which uses flagged items, if nothing is highlighted - to use anything with a context set to iCal (or whatever context other users prefer). Am I making any sense? Sorry, I'm not very good with this stuff.

As always, thanks a ton for your help! I really appreciate it.

Best Wishes, Jason
Oops, I see that I forgot to elide a clause from the conditional that assembles the list of tasks!

				set TaskList to TaskList & (tasks of currentContext where blocked is false and flagged is true and completed is false)
should instead be:

				set TaskList to TaskList & (tasks of currentContext where blocked is false and completed is false)
Otherwise, you'd only get tasks in the desired context which happened to be flagged. As it turns out, for the context I used as my test case, they were...

Don't forget that you have to edit the property contextIfNoSelection to have the name of your desired context (sounds like "iCal" is the right value).
Brian - the script works perfectly now! I can't thank you enough!!

For those that are interested, I have posted the script here:

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sync iCal events into OmniFocus SpiralOcean OmniFocus 1 for Mac 4 2012-04-16 11:35 AM
Sync tasks with due-dates to iCal-calendar? [See "Replacing Calendar Sync" thread.] tkaufmann iCal Sync 34 2011-02-10 04:25 PM
Is there a way to get OF tasks that have Due Dates to appear in iCal as Events? martlume OmniFocus for iPhone 2 2009-01-13 04:30 PM
Any way to sync to iCal dates? TV Dog iCal Sync 3 2008-01-12 04:21 PM
Dates wrong after sync in iCal tastiger iCal Sync 13 2007-12-10 08:00 AM

All times are GMT -8. The time now is 07:15 AM.

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