Skip to content

Instantly share code, notes, and snippets.

@mattpetters
Last active April 8, 2017 20:40
Show Gist options
  • Save mattpetters/f295a67313402cc3e3c6b1978300a1c4 to your computer and use it in GitHub Desktop.
Save mattpetters/f295a67313402cc3e3c6b1978300a1c4 to your computer and use it in GitHub Desktop.
Applescript for Omnifocus that outputs a string with a random due soon task, the number of due soon tasks, and number of flagged tasks
tell application "OmniFocus"
tell front document
-- Get the list of tasks
set theDueTasks to every flattened task where its completed = false and due date is greater than (current date) and due date is less than (current date) + (7 * days)
set theFlaggedTasks to every flattened task where its flagged = true and completed = false
set dueCount to count of theDueTasks
set flagCount to count of theFlaggedTasks
if theDueTasks is not equal to {} then
-- get a random number
set randomNumber to (random number from 1 to dueCount)
set currentTask to item randomNumber of theDueTasks
set dueDate to due date of currentTask
set reportText to " ☯ Due Soon: " & dueCount & " | ⚐ Flagged: " & flagCount & " | " & name of currentTask & " "
return reportText
end if
end tell -- end tell front document
end tell -- end tell application "OmniFocus"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment