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

 
Script: Export (from an 'iCal' context) to iCal Thread Tools Search this Thread Display Modes
A quick draft of yet another script which updates an "OmniFocus" calendar in iCal with the current set of incomplete tasks in any 'iCal' context in OF.

Similar in function (though not coding) to Yang Yilei and Mike Erickson's drafts, but may be a little faster, and reports on how many tasks, if any, are involved.

Code:
property pTitle : "OmniFocus to iCal"
property pVer : "0.1"

-- Exports any tasks in context "iCal"
-- to an "OmniFocus" calendar in the iCal app

property pCalendar : "OmniFocus"
property pContext : "iCal"

property pblnAlarm : true
property pAlarmWhen : -20
property pAlarmWhat : "Glass"

tell application id "OFOC"
	tell default document
		set lstContext to flattened contexts where name is pContext
		if lstContext ≠ {} then
			set oContext to first item of lstContext
		else
			set oContext to make new context with properties {name:pContext}
		end if
		
		tell (flattened tasks where its context is oContext and completed is false)
			set {lstName, lstNote, lstStart, lstDue} to {name, note, start date, due date}
		end tell
	end tell
end tell

set lngName to length of lstName
if lngName < 1 then
	display dialog "No uncompleted tasks found in the iCal context ..." buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
	return
end if

tell application id "wrbt"
	set lstCal to calendars where title = pCalendar
	if lstCal ≠ {} then
		set oCalendar to first item of lstCal
	else
		set oCalendar to make new calendar with properties {title:pCalendar}
	end if
	
	tell oCalendar
		delete events
		delete todos
		repeat with i from 1 to length of lstName
			set {dteStart, dteDue} to {item i of lstStart, item i of lstDue}
			tell (make new event with properties {summary:item i of lstName, description:item i of lstNote})
				if (dteStart is missing value and dteDue is missing value) then
					set allday event to true
				else
					if dteStart is not missing value then set start date to dteStart
					if dteDue is not missing value then set end date to dteDue
				end if
				
				if pblnAlarm then make new sound alarm with properties {trigger interval:pAlarmWhen, sound name:pAlarmWhat}
			end tell
		end repeat
	end tell
end tell

display dialog (lngName as string) & " task(s) exported from the iCal context
to the OmniFocus calendar in iCal." buttons {"OK"} default button "OK" with title pTitle & "  ver. " & pVer
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
iCal export script? VinnyTroia iCal Sync 1 2013-01-16 09:16 PM
Script to copy iCal todos into Omnifocus inbox? danielcompton OmniFocus Extras 7 2010-09-04 06:01 PM
iCal Sync - 1 Context -> 2 iCal Calendars visionsnap OmniFocus 1 for Mac 3 2010-01-16 07:00 PM
script? to make iCal event pjb iCal Sync 6 2007-06-13 02:07 PM
iCal export: export to completion date? jashmenn OmniPlan General 1 2007-02-23 12:41 PM


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


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