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

 
Add Text to the Start of an Action Thread Tools Search this Thread Display Modes
Quote:
Originally Posted by Christian View Post

I basically have no idea of coding, all I do sometimes is to take scripts that look remotely like what I want and try to figure out which parts/variables to modify to make "my" script. From what I can tell that put-into-folder-assign-tag would need the "on run" part to be replaced with some sort of trigger that activates when I put one or more actions into a certain context. Tht leaves me with one question though: how the hell do I do that? :p
You don't. As Lizard said, it will have to be a script you run after making some changes. Curt Clifton wrote a script years ago called Verify Next Action Exist that is similar in concept run it periodically and it marks various projects that meet some criteria.
 
Quote:
Originally Posted by skillet View Post
I'm pretty sure this can't be done currently in OmniFocus because all the colors of actions and projects etc are handled globally in preferences and not individually.
Correct, the status-based styling OF does of actions includes color, and you aren't able to override it.
 
I see. Well at least I didn't do it wrong then ;)

To make a script that does "on run, check all items in context X for being tagged with Y. Add Y to Items not already tagged." I would need the syntax for that specific context. Does OF have some sort of library where I can look those variables up?
 
As usual, the simple case is simple, and the rest, well, not as simple :-)

If you only have a flat list of contexts in your database, and you've got a task in oTask,

Code:
 name of context of oTask
would give you the name of that context. However, if you might have a nested context, like Errands : Downtown, the name of that context is only going to be Downtown, and you'll have to tiptoe through the tree structures (with apologies to Tiny Tim) to figure out the whole thing. Here's a sample piece of code that simply prints out the names of the contexts of the selected items:

Code:
tell application "OmniFocus"
	local strCt
	tell front document
		tell document window 1
			set strMessage to "Contexts of selected actions are:" & return & return
			set oTrees to selected trees of content
			set lngTrees to count of oTrees
			if (lngTrees > 0) then
				repeat with iTree from 1 to lngTrees
					set oTask to value of (item iTree of oTrees)
					set strMessage to strMessage & space & my ContextName(oTask) & return
				end repeat
				display alert strMessage
			else
				display alert "No content selected!"
			end if
		end tell
	end tell
end tell

-- return full name of context, or "(None)"
-- uses ":" as hierarchy separator, as OmniFocus does not appear to expose 
-- the value conveniently
on ContextName(oTask)
	using terms from application "OmniFocus"
		local oContext
		local strContextName
		
		set strContextName to ""
		set oContext to context of oTask
		if (oContext is missing value) then
			return "(None)" -- easy case!
		end if
		
		-- if there is a context set, we need to construct the full name, 
		-- climbing up the tree to the top.  We take the name of our starting
		-- point, then look at the container.  Each time the container is not
		-- of class document, there's another layer, and we tack its name on
		-- to the front of the string.  
		set strContextName to name of oContext
		repeat while (class of (container of oContext) is not document)
			set strContextName to ":" & strContextName
			set oContext to container of oContext
			set strContextName to name of oContext & strContextName
		end repeat
		return strContextName
	end using terms from
end ContextName
 
I'll point out that the script that puts a string at the beginning of the row could be modified to check if the string is already there and skip that row if so. Google Applescript string manipulation and you should find some reading material that will help you figure it out; I'll help if you get stuck. With the script so modified, you could just bring up a context view with that context selected and remaining actions shown, select all, and run the script. Later on in the class you'll learn how to have your script select those rows without your assistance :-)
 
That's pretty cool and complicated, thanks for sharing your skills! I need to quit my day job so I can sit and figure this stuff out ;).
 
Quote:
Originally Posted by Christian View Post

I basically have no idea of coding, all I do sometimes is to take scripts that look remotely like what I want and try to figure out which parts/variables to modify to make "my" script.
Christian, just incase you are interested I thought I'd post this link it uses this script. It does a lot of other neat things in conjunction with it, thanks to whpalmer4 (and others).

See post 8 in particular.

Last edited by skillet; 2011-09-17 at 05:50 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted Loc. reminders now for an action due in Jan [A: add start date to action] jman995x OmniFocus for iPhone 4 2011-12-01 01:39 PM
Should I start with the Text Editor example? gopi Omni Frameworks 4 2010-09-14 10:28 PM
Action status: "next action" and start dates dondo OmniFocus 1 for Mac 3 2008-08-06 08:48 PM
Start / end of line key nav inside text object ? Leon Starr OmniGraffle General 2 2008-07-02 12:11 PM
Possible to search Action text containing text value? Journey OmniFocus 1 for Mac 3 2007-11-28 03:25 PM


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


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