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

 
Applescripting Thread Tools Search this Thread Display Modes
All,

I did lots of searching high and low on some simple scripts for OF. I am a real simple user of OF right now, use the Inbox and Context. I do not assign much to a project yet as I do not have that much detail yet on tasking. Here is my work flow.

Place a item into my Inbox with a Context, usually Office, with a due date, usually within 2 - 4 weeks. I then use the Due Date as a place to see what is due for the week and what is past due.

What I am trying to achieve with this post is how can I get some help or better on a script I found and have made some modifications to.

Goal of script: Generate a report of items I Completed for the past week and what I have due in the next week. I have it working in a very simple way, look at Inbox, look at completed date and store it, then cut some ID's out and send it to mail, not in date order.

What I want help with if possible:

1. When I add the notes to the name of the task I want to be able to indent that 2 - 3 tabs under item. When I do this I want to then just sort on name not everything.
2. I will tinker with this however how can I look at items that are over due and create a separate list to report out to mail.

Here is the code, let me know if anyone has ideas. Thanks a bunch.

-
Code:
-Setting what you want the report to look like, names, emails, etc.

property pstrSubject : "Status Report"
property pstrGreeting : "Name"
property pstrThisWeekHdr : "Here's what I did this week:"
property pstrNextWeekHdr : "Here's what I plan on doing next week:"
property pstrPastdueHdr : "Past due items that need to be completed:"
property pstrRecpName : "Omni"
property pstrRecpAddr : "omni@omni.com"

property dteNow : current date
property dteHistory : dteNow - (7 * days)
property dteFuture : dteNow + (7 * days)
property dtePastdue : dteNow - (7 * days)
property dteFuture2 : dteNow - (0 * days)
property pdteBase : missing value

on run
	-- Verify you have a date to start with so you can see what you did previous and furture, setable above in History and Future.
	if pdteBase is missing value then
		set pdteBase to dteNow
		tell pdteBase
			set {its year, its month, its day, its time} to {2014, 1, 1, 0}
		end tell
	end if
	
	# modification and (completion date is missing value) and (modification date < dteHistory)
	
	tell application "OmniFocus"
		tell front document
			-- Set what you want to look at based on some logic on dates.  One thing I am trying to do here also is only look at Office context versus everything.
			--Working on setting context here.  I beleive when I get to reference I can do this?
			set office to first flattened context where name is "Office"
			set refHistory to a reference to (flattened tasks where (in inbox = true and its completion date > dteHistory))
			set refFuture to a reference to (flattened tasks where (in inbox = true) ¬
				and (due date > dteFuture2) and (due date < dteFuture))
			#set refPastdue to a reference to (flattened tasks where (in inbox = true and its due date < dtePastdue))
			
			-- Get the data I want to display for a email to be used later.  Would like to understand how to format better.
			set {lstHDate, lstName, lstNote} to {completion date, name, note} of refHistory
			repeat with i from 1 to length of lstHDate
				set dte to item i of lstHDate
				set item i of lstHDate to ((dte - pdteBase) as string) & tab & short date string of dte & tab & item i of lstName & tab & item i of lstNote
			end repeat
			
			--Items that are due 7 days from when you run this.
			set {lstFDate, lstName, lstNote} to {due date, name, note} of refFuture
			repeat with i from 1 to length of lstFDate
				set dte to item i of lstFDate
				set item i of lstFDate to ((dte - pdteBase) as string) & tab & short date string of dte & tab & item i of lstName & tab & item i of lstNote
			end repeat
			
			
		end tell
	end tell
	
	-- Sort by date and remove extra lines for easy reading.
	-- (setting line delimiter to \n in preparation for sorting lines in the shell)
	set text item delimiters to "
"
	#set strPastdue to do shell script "echo " & quoted form of (lstFDate as string) & " | sort -k 1,3 | cut -f 2,3" 
	set strThisWeek to do shell script "echo " & quoted form of (lstHDate as string) & " | cut -f 2,3"
	set strNextWeek to do shell script "echo " & quoted form of (lstFDate as string) & " | cut -f 2,3"
	set my text item delimiters to space
	
	set strMsg to (pstrGreeting & "

" & pstrThisWeekHdr & "

" & strThisWeek) & "

" & pstrNextWeekHdr & "

" & strNextWeek
	
	
	tell application "Mail"
		tell (make new outgoing message with properties {visible:true, subject:pstrSubject, content:strMsg})
			make new to recipient at end of to recipients with properties {name:pstrRecpName, address:pstrRecpAddr}
		end tell
		activate
	end tell
end run
 
All,

So I was able to get things done the way I wanted without any help on my post.

A few questions to the user or administrators on this forum:

When I want to look at my Inbox and only return context of office, what is the syntax for that?

Here is what I have now, can someone help me make it work? I am trying to set a variable called office to context office then just return the values. I may be way off and I think I am...

Code:
set office to first flattened context where name is "Office"
			set refHistory to a reference to (flattened tasks where (in inbox = true and its completion date > dteHistory))
			set refFuture to a reference to (flattened tasks where (in inbox = true) ¬
				and (due date > dteFuture2) and (due date < dteFuture))
			#set refPastdue to a reference to (flattened tasks where (in inbox = true and its due date < dtePastdue))
			
			-- Get the data I want to display for a email to be used later.  Would like to understand how to format better.
			set {lstHDate, lstName, lstNote} to {completion date, name, note} of refHistory
			repeat with i from 1 to length of lstHDate
				set dte to item i of lstHDate
				set item i of lstHDate to ((dte - pdteBase) as string) & tab & short date string of dte & tab & item i of lstName --& tab & item i of lstNote
			end repeat
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes



All times are GMT -8. The time now is 03:30 AM.


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