Repeating Tasks
Omni Automation in OmniFocus provides the ability to set the repetition rules for a task. The repetitionRule property of the Task class is used to access and set any repeating parameters.
repetitionRule (Task.RepetitionRule or null) • If repetition is enabled for the task, the value of this task property is an instance of the Task.RepetitionRule class.
The Task.RepetitionRule Class
A Task.RepetitionRule describes a pattern of dates using a ICS formatted recurrence string (iCalendar.org) and a Task.RepetitionMethod to describe how those dates are applied to a Task.
The properties of the Task.RepetitionRule class:
method (Task.RepetitionMethod r/o) • The method used to create the repetition rule.
ruleString (String r/o) • The ICS rule string used to create the repetition rule.
anchorDateKey (Task.AnchorDateKey r/o) • (v4.7+) The date property to use when updating a repeating item for its next occurrence.
catchUpAutomatically (Boolean r/o) • (v4.7+) Whether, when resolved, this item automatically skips any occurrences in the past (applies only to regularly repeating items).
scheduleType (Task.RepetitionScheduleType r/o) • (v4.7+) Explains how the ruleString will be applied when creating subsequent occurrences for a Task that repeats. Used to represent when items repeat regularly from their assigned dates, calculate their next occurrence when resolved (i.e. completed or dropped), or have no repeat.
The instance functions of the Task.RepetitionRule class:
firstDateAfterDate(date: Date) → (Date) • Returns the first date described by the repetition rule that is after the given date.
Date/Time of the Next Task Repetition
var task = document.windows[0].selection.tasks[0]
if(task && task.repetitionRule){
console.log(task.name, task.repetitionRule.firstDateAfterDate(new Date()))
}
The Task.RepetitionMethod Class
DeferUntilDate (Task.RepetitionMethod r/o) • XXXXX
DueDate (Task.RepetitionMethod r/o) • XXXXX
Fixed (Task.RepetitionMethod r/o) • Task.RepetitionMethod r/o) • XXXXX
None (Task.RepetitionMethod r/o) • The task does not repeat.
all (Array of Task.RepetitionMethod r/o) • An array of all items of this enumeration. Often used when creating action forms.
Task.RepetitionRule Constructor
Task.RepetitionRule Constructor
new Task.RepetitionRule(
ruleString: String or null,
method: Task.RepetitionMethod or null,
scheduleType: Task.RepetitionScheduleType or null,
anchorDateKey: Task.AnchorDateKey or null,
catchUpAutomatically: Boolean or null
)
Returns a new Task.RepetitionRule with the specified ICS rule string and scheduling information. If the rule string is not valid, an error will be thrown. The system defaults will be used for ruleString, scheduleType, anchorDateKey, and catchUpAutomatically if not provided.
IMPORTANT: The method parameter is deprecated, but remains for backwards compatibility with existing scripts and scheduleType should be used instead. If deprecated method is provided along with updated scheduleType and anchorDateKey, an error will be thrown.
Properties of Task.RepetitionScheduleType Class
FromCompletion (Task.RepetitionScheduleType r/o) •
None (Task.RepetitionScheduleType r/o) • The task does not repeat.
Regularly (Task.RepetitionScheduleType r/o) •
all (Array of Task.RepetitionScheduleType) • Used for creating for plug-in form menus.
Schedule Type
var scheduleType = Task.RepetitionScheduleType.Regularly
Properties of Task.AnchorDateKey Class
DeferDate (Task.AnchorDateKey r/o) •
DueDate (Task.AnchorDateKey r/o) •
PlannedDate (Task.AnchorDateKey r/o) •
all (Array of Task.AnchorDateKey) • Used for creating for plug-in form menus.
Anchor Date Key
var anchorDateKey = Task.AnchorDateKey.DueDate
Create Repeating Task
Creating a new repeating task:
New Repeating Task
task = new Task("My Weekly Task")
ruleString = "FREQ=WEEKLY"
repetitionMethod = Task.RepetitionMethod.DueDate
task.repetitionRule = new Task.RepetitionRule(ruleString, repetitionMethod)
task.url.open()
Using OmniFocus v4.7+ parameters. NOTE: The method parameter is included with a value of null
New Repeating Task (v4.7+)
task = new Task("My Weekly Task")
task.repetitionRule = new Task.RepetitionRule(
"FREQ=WEEKLY",
null,
Task.RepetitionScheduleType.Regularly,
Task.AnchorDateKey.DueDate,
true
)
task.url.open()
And to disable repetition, set the property value to null:
Stop Repetition
var task = taskNamed("My Weekly Task")
task.repetitionRule = null
The Rule Info Plug-In
Aside from using the free RRULE Tool at iCalendar.org, perhaps the simplest way to derive an ICS rule string is to set up an example repeating task in OmniFocus using the standard application interface, and then use Omni Automation to retrieve the corresponding ISC rule string from the selected task. You can then use the extracted ICS rule string in your scripts to define the specified repetition parameters.
The plug-in provided below will both display the ICS string and log it to the console for you.

Rule Info for Selected Task
/*{
"type": "action",
"targets": ["omnifocus"],
"author": "Otto Automator",
"identifier": "com.omni-automation.of.task-rule-info",
"version": "1.1",
"description": "This action will display an alert showing the ICS rule string and repetition method of the selected task or project.",
"label": "Rule Info for Selected Item",
"shortLabel": "Rule Info",
"paletteLabel": "Rule Info",
"image": "info.square.fill"
}*/
(() => {
const action = new PlugIn.Action(async function(selection, sender){
if (selection.projects.length === 1){
var item = selection.projects[0]
var alertTitle = "Project: " + item.name
} else {
var item = selection.tasks[0]
var alertTitle = "Task: " + item.name
}
rule = item.repetitionRule
ruleString = item.repetitionRule.ruleString
repetitionMethod = item.repetitionRule.method
msg = ""
var methodName
switch(repetitionMethod) {
case Task.RepetitionMethod.DueDate:
methodName = "Due Date"
break;
case Task.RepetitionMethod.Fixed:
methodName = "Fixed"
break;
case Task.RepetitionMethod.DeferUntilDate:
methodName = "Defer Until Date"
break;
default:
methodName = "None"
}
msg = "ICS Rule String: " + ruleString + "\n" + "Repetition Method: " + methodName
console.log(msg)
new Alert(alertTitle, msg).show()
});
action.validate = function(selection, sender){
return (
selection.projects.length === 1 &&
selection.projects[0].repetitionRule != null ||
selection.tasks.length === 1 &&
selection.tasks[0].repetitionRule != null
)
};
return action;
})();

Repeating Project with Sequential Tasks
This example demonstrates repetition through the tasks required to create and present a kindergarten class every week. Each task has a morning notification and evening due date. Once the project’s sequential tasks are completed, the project is marked completed and a new blank project is generated as its replacement.
Kinder Class
formatter = Formatter.Date.withStyle(Formatter.Date.Style.Short)
folder = folderNamed("Personal") || new Folder("Personal")
projectName = "Kinder Class"
project = folder.projectNamed(projectName)
if(project){deleteObject(project)}
project = Object.assign(
new Project(projectName, folder),
{
sequential : true,
note : "My weekly kindergarten class"
}
)
tag = flattenedTags.byName("Instruction") || new Tag("Instruction")
project.addTag(tag)
ruleString = "FREQ=WEEKLY"
repetitionMethod = Task.RepetitionMethod.DueDate
project.repetitionRule = new Task.RepetitionRule(ruleString, repetitionMethod)
project.completedByChildren = true
task = Object.assign(
new Task("(Wed) Select Topic for Kinder Class", project),
{
note : "Determine a topic for this week’s class",
dueDate: formatter.dateFromString('wednesday @ 7:00PM')
}
)
dateObj = formatter.dateFromString('wednesday @ 9:00AM')
task.addNotification(dateObj)
task.clearTags()
task = Object.assign(
new Task("(Thu) Create Materials for Kinder Class", project),
{
note : "Create materials for this week’s class",
dueDate: formatter.dateFromString('thursday @ 7:00PM')
}
)
dateObj = formatter.dateFromString('thursday @ 9:00AM')
task.addNotification(dateObj)
task.clearTags()
task = Object.assign(
new Task("(Sat) Kinder Class Rehearsal", project),
{
note : "Rehearse Kinder Class presentation",
dueDate: formatter.dateFromString('saturday @ 7:00PM')
}
)
dateObj = formatter.dateFromString('saturday @ 9:00AM')
task.addNotification(dateObj)
task.clearTags()
task = Object.assign(
new Task("(Sun) Kinder Class", project),
{
note : "Kinder Class",
dueDate : formatter.dateFromString('sunday @ 11:30AM')
}
)
task.addNotification(-3600)
dateObj = formatter.dateFromString('sunday @ 9:00AM')
task.addNotification(dateObj)
task.clearTags()
