The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 3 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=9)
-   -   OverDue Due Date Highlighter (http://forums.omnigroup.com/showthread.php?t=4978)

bgeipel 2007-09-26 01:33 PM

OverDue Due Date Highlighter
 
Hi all,

I wrote this script to highlight rows that have a due date that is today or earlier and have not yet been checked. If the row does not have a due date, it looks up the parent chain for one and inherits that due date.

This is my very first AppleScript so be gentle and use at your own risk,

--------------------

(*
OverDue Highlighter
Copyright 2007 Barry Geipel - [email]barry@GeipelNet.com[/email]

Install this in HOME/Library/OmniOutliner Pro/Scripts

You will need to turn off Automatic Line Styles
Format->Automatic Line Styles

*)

tell application "OmniOutliner Professional"

set ThisDocument to front document of application "OmniOutliner Professional"
set nowTime to current date


tell application "OmniOutliner Professional" to tell ThisDocument
try
set overDueStyle to named style "Overdue"
get overDueStyle
on error
set overDueStyle to make new named style with properties {name:"Overdue"}
set value of attribute "font-fill" of overDueStyle to {55838, 634, 634}
end try
end tell

-- find columns we can use for due date
set dueColumnNum to 0

set columnCount to count of columns of ThisDocument
if columnCount > 2 then
repeat with i from 1 to columnCount
set theColumn to column i of ThisDocument
set colType to type of theColumn

if colType is date and name of theColumn contains "due" then
set dueColumnNum to i
exit repeat
end if
end repeat
end if

repeat with theRow in (every row of ThisDocument)
named styles of style of theRow
remove overDueStyle from named styles of styles of theRow

set testRow to theRow
set dueDate to value of cell dueColumnNum of testRow
repeat until dueDate is not missing value
try
set testRow to parent of testRow
set dueDate to value of cell dueColumnNum of testRow
on error
exit repeat
end try
end repeat

if dueDate is not missing value then
if state of theRow is not checked then
if dueDate comes before nowTime then
named styles of style of theRow
add overDueStyle to end of named styles of style of theRow
end if
end if
end if

end repeat

end tell


All times are GMT -8. The time now is 02:48 AM.

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