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

 
AppleScript: Transfer tasks from THL (The Hit List) to OmniFocus Thread Tools Search this Thread Display Modes
I am currently using The Hit List (used OmniFocus, but then moved to Things, and then to THL).

However, I will be getting an iPhone soon and as THL does not as of yet have an iPhone app, I wanted to move back to OF (as Things does not quite work like I want it to).

THL does not export stuff, but it does support AppleScript, so I wrote a small script that creates new tasks in the OmniFocus Inbox using the current selected tasks in THL. Here is the script just in case somebody else needs to move.

You still have to do manual work, but not as much as you would have to. It would be possible to create a script that traverses the folder and list structure of THL and replicates it in OmniFocus, but this is Good Enough™ for me.

Code:
tell application "The Hit List"
	activate
	set tasklist to selection
	set singleTask to true
	
	if tasklist is not {} then
		repeat with theTask in tasklist
			set theStart to missing value
			set theDue to missing value
			set theOmniTask to missing value
			
			set theTitle to the title of theTask
			set theNotes to the notes of theTask
			set theStart to the start date of theTask
			set theDue to the due date of theTask
			
			tell application "OmniFocus"
				tell default document
					set newTaskProps to {name:theTitle}
					if theStart is not missing value then set newTaskProps to newTaskProps & {start date:theStart}
					if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
					if theNotes is not missing value then set newTaskProps to newTaskProps & {note:theNotes}
					
					set newTask to make new inbox task with properties newTaskProps
				end tell
			end tell
		end repeat
	end if
end tell
 
Quote:
Originally Posted by eatmytag View Post
I am currently using The Hit List (used OmniFocus, but then moved to Things, and then to THL).

However, I will be getting an iPhone soon and as THL does not as of yet have an iPhone app, I wanted to move back to OF (as Things does not quite work like I want it to).

THL does not export stuff, but it does support AppleScript, so I wrote a small script that creates new tasks in the OmniFocus Inbox using the current selected tasks in THL. Here is the script just in case somebody else needs to move.

You still have to do manual work, but not as much as you would have to. It would be possible to create a script that traverses the folder and list structure of THL and replicates it in OmniFocus, but this is Good Enough™ for me.

Code:
tell application "The Hit List"
	activate
	set tasklist to selection
	set singleTask to true
	
	if tasklist is not {} then
		repeat with theTask in tasklist
			set theStart to missing value
			set theDue to missing value
			set theOmniTask to missing value
			
			set theTitle to the title of theTask
			set theNotes to the notes of theTask
			set theStart to the start date of theTask
			set theDue to the due date of theTask
			
			tell application "OmniFocus"
				tell default document
					set newTaskProps to {name:theTitle}
					if theStart is not missing value then set newTaskProps to newTaskProps & {start date:theStart}
					if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
					if theNotes is not missing value then set newTaskProps to newTaskProps & {note:theNotes}
					
					set newTask to make new inbox task with properties newTaskProps
				end tell
			end tell
		end repeat
	end if
end tell
That's awesome, where were you a week ago when I bailed on THL. ;)

Thanks,

Scott
 
Quote:
Originally Posted by scottrych View Post
That's awesome, where were you a week ago when I bailed on THL. ;)

Thanks,

Scott
Why did you quit THL? I miss stuff from THL, any adaptation tips now that I am back to OF? I had tasks tagged in THL, how do you solve that in OF?
 
Alright, I'm not trying to stir stuff up but I do like using THL sometimes for shorter lists and haven't found an easy way to make a punch list in OF. My questions are can you make a shorter list in OF and how does one go about transferring from OF to THL. Does somebody know how to do either of these, and yes I will also post to the req. features section because overall I like OF better. Thanks for ANY help provided. Cheers.
Shawn
 
Perhaps for those of us (most?) who don't use The Hit List, you could give us a picture or something to illustrate what it is that you want.
 
Quote:
Originally Posted by heidesw View Post
Alright, I'm not trying to stir stuff up but I do like using THL sometimes for shorter lists and haven't found an easy way to make a punch list in OF. My questions are can you make a shorter list in OF and how does one go about transferring from OF to THL. Does somebody know how to do either of these, and yes I will also post to the req. features section because overall I like OF better. Thanks for ANY help provided. Cheers.
Shawn
You can make as short lists as you want in OF.. maybe you are looking for the "single actions" option. Select a list, then open the inspector and change the list (project) type to "single action" (the shoe box).

BTW: A note on terminology. OF Projects = THL Lists. OF Action = THL Task. IMHO, THL terminology is more intuitive, but not as GTD.
 
Ok, so I am moving back to THL. Just because I want to remember what the difference was, and because there might be a way for me sync THL and an IPhone.

So I made this script:

Code:
-- -------------------------------
-- This gets run from the tool bar
-- -------------------------------
on run
	tell application "OmniFocus"
		tell document window 1 of front document
			set listTrees to selected trees of content
			if (count of listTrees) = 0 then
				try
					display dialog "No tasks selected." & return
				end try
			else
				my ExportTrees(listTrees)
			end if
		end tell
	end tell
	
	-- show the results in THL
	activate application "The Hit List"
end run


-- ------------------------------------------------------------
-- Traverses the OmniFocus tree and create a task for each node
-- ------------------------------------------------------------
on ExportTrees(listTrees)
	
	using terms from application "OmniFocus"
		repeat with oTree in listTrees
			
			-- intialize task string
			set notes to ""
			set tags to ""
			set strName to ""
			set isDone to false
			
			-- get actual tree?
			set oValue to value of oTree
			
			-- Inbox does not have a name?
			try
				set strName to name of oValue
			on error
				set strName to "Inbox"
			end try
			
			-- get note if not Inbox
			if strName ≠ "Inbox" then
				set strNote to note of oValue
			end if
			
			-- get object class
			set clValue to class of oValue
			
			-- Get the context
			set oContext to context of oValue
			if oContext is not equal to missing value then
				set tags to " @" & name of oContext & " "
			end if
			
			set dteStart to start date of oValue
			set dteDue to due date of oValue
			set estimate to estimated minutes of oValue
			
			if flagged of oValue then
				set tags to tags & " @flag" & " "
			end if
			
			if completed of oValue then
				set isDone to true
			end if
			
			-- get any trees of the current tree if possible (sub trees)
			set lstSubTrees to trees of oTree
			
			-- if tree has sub trees
			if (count of lstSubTrees) > 0 then
				-- create task and move down tree
				my createTHLTask(strName & tags, notes, dteStart, dteDue, estimate, isDone)
				ExportTrees(lstSubTrees)
			else
				-- else, just create task
				my createTHLTask(strName & tags, notes, dteStart, dteDue, estimate, isDone)
			end if
		end repeat
	end using terms from
end ExportTrees


-- -------------------------------------
-- Create a task in the current THL list
-- -------------------------------------
on createTHLTask(theTitle, theNotes, theStartDate, theDuedate, theEstimate, theIsDone)
	-- create the record to use to create a task
	using terms from application "The Hit List"
		set params to {title:theTitle}
		if theDuedate is not missing value then
			set params to params & {due date:theDuedate}
		end if
		if theStartDate is not missing value then
			set params to params & {start date:theStartDate}
		end if
		if theNotes is not missing value then
			set params to params & {notes:theNotes}
		end if
		if theEstimate is not missing value then
			set params to params & {estimated time:theEstimate * 60}
		end if
	end using terms from
	
	-- create the task in the current THL list
	tell application "The Hit List"
		set activeGroup to get selected group
		tell activeGroup to make new task with properties params
	end tell
end createTHLTask
It's based on this Omnifocus to Things script: http://coach.vaidabogdan.com/2009/09...to-things.html

To use the script, copy it into
Code:
~/Library/Scripts/Applications/Omnifocus
then restart OmniFocus and create a toolbar item from the script.

cheers!
 
Modified to allow note import:

Code:
-- -------------------------------
-- This gets run from the tool bar
-- -------------------------------
on run
	tell application "OmniFocus"
		tell document window 1 of front document
			set listTrees to selected trees of content
			if (count of listTrees) = 0 then
				try
					display dialog "No tasks selected." & return
				end try
			else
				my ExportTrees(listTrees)
			end if
		end tell
	end tell
	
	-- show the results in THL
	activate application "The Hit List"
end run


-- ------------------------------------------------------------
-- Traverses the OmniFocus tree and create a task for each node
-- ------------------------------------------------------------
on ExportTrees(listTrees)
	
	using terms from application "OmniFocus"
		repeat with oTree in listTrees
			
			-- intialize task string
			set notes to ""
			set tags to ""
			set strName to ""
			set isDone to false
			
			-- get actual tree?
			set oValue to value of oTree
			
			-- Inbox does not have a name?
			try
				set strName to name of oValue
			on error
				set strName to "Inbox"
			end try
			
			-- get note if not Inbox
			-- if strName ≠ "Inbox" then
			set strNote to note of oValue
			-- end if
			
			-- get object class
			set clValue to class of oValue
			
			-- Get the context
			set oContext to context of oValue
			if oContext is not equal to missing value then
				set tags to " @" & name of oContext & " "
			end if
			
			set dteStart to start date of oValue
			set dteDue to due date of oValue
			set estimate to estimated minutes of oValue
			
			if flagged of oValue then
				set tags to tags & " @flag" & " "
			end if
			
			if completed of oValue then
				set isDone to true
			end if
			
			-- get any trees of the current tree if possible (sub trees)
			set lstSubTrees to trees of oTree
			
			-- if tree has sub trees
			if (count of lstSubTrees) > 0 then
				-- create task and move down tree
				my createTHLTask(strName & tags, strNote, dteStart, dteDue, estimate, isDone)
				ExportTrees(lstSubTrees)
			else
				-- else, just create task
				my createTHLTask(strName & tags, strNote, dteStart, dteDue, estimate, isDone)
			end if
		end repeat
	end using terms from
end ExportTrees


-- -------------------------------------
-- Create a task in the current THL list
-- -------------------------------------
on createTHLTask(theTitle, theNotes, theStartDate, theDuedate, theEstimate, theIsDone)
	-- create the record to use to create a task
	using terms from application "The Hit List"
		set params to {title:theTitle}
		if theDuedate is not missing value then
			set params to params & {due date:theDuedate}
		end if
		if theStartDate is not missing value then
			set params to params & {start date:theStartDate}
		end if
		if theNotes is not missing value then
			set params to params & {notes:theNotes}
		end if
		if theEstimate is not missing value then
			set params to params & {estimated time:theEstimate * 60}
		end if
	end using terms from
	
	-- create the task in the current THL list
	tell application "The Hit List"
		set activeGroup to get selected group
		tell activeGroup to make new task with properties params
	end tell
end createTHLTask
What was changed: Notes variable was named incorrectly; removed limitation of inbox items not passing on notes.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
AppleScript that adds Waiting For emails from Mail.app (delegated tasks) to OmniFocus simplicitybliss OmniFocus Extras 139 2014-01-16 12:25 PM
How do I transfer from OmniOutliner to OmniFocus? neilcowley OmniFocus 1 for Mac 2 2008-07-29 04:43 PM
OmniFocus: Querying tasks in Applescript gives odd results RobTrew AppleScripting Omni Apps 0 2008-03-01 01:03 AM
Applescript error: reading the property list of non-inbox tasks RobTrew OmniFocus Extras 1 2008-01-13 11:33 PM
Applescript Help: getting a list of tasks tweir OmniPlan General 3 2007-01-10 02:33 PM


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


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