Dependencies
When a task must be completed before another can begin, a dependency exists between them. Charting dependencies in your project is a key part of understanding the critical path of tasks that leads through to its successful completion, on time and within budget.
Using the Gantt chart in Task View, you can represent the relationships between tasks with dependency lines. A dependency line is drawn from the beginning or end of one task (or group, or milestone) to the beginning or end of another.
When you create a dependency, the dependent task automatically reschedules itself to respect the dependency. With further changes to the schedule and leveling, the tasks continue trying to follow the dependencies. If a dependency becomes impossible or you manually cause a task to stop obeying its dependencies, a violation occurs, which can be resolved with the Violations window.
The Omni Automation support in OmniPlan is particularly useful for automating the creation and setup of tasks and their related dependencies.
Instance Properties
The properties of a dependency.
dependent (Task) • The dependent of this dependency, which is the target Task whose schedule is effected.
dependentAlignedToEnd (Boolean) • Whether this dependency aligned to the start or the end date of its dependent task. A value of true indicates the dependency between the tasks begins at the end of the first task.
kind (DependencyKind) • The kind of dependency.
leadTimeDuration (Duration or null) • The lead time before the dependent task, as a duration object.
leadTimePercentage (Number or null) • The lead time before the dependent task, as a percentage of the duration of the prerequisite.
prerequisite (Task r/o) • The prerequisite of this dependency, which is the source Task that helps determine when the target Task is scheduled.
prerequisiteAlignedToEnd (Boolean) • Whether this dependency aligned to the start or the end date of its prerequisite task.
Instance Functions
The functions that may be applied to an instance of a dependency.
remove() • Call to delete this dependency, removing it from it’s prerequisite and dependent tasks.
DependencyKind
OmniPlan supports four types (*) of dependencies that describe the ways in which tasks relate to one another. The dependency connection between two tasks can be tethered at either the beginning or end of task.
FinishFinish* (DependencyKind r/o) • With Finish to Finish, when the first task ends, then the second one can end; the tasks may overlap.
FinishStart* (DependencyKind r/o) • With Finish to Start, the first task must end before the second task can start; the tasks must not overlap except at the instant the first one ends. This is the most common type of dependency, and the kind that you get when you connect two selected tasks by clicking the Connection button in the toolbar.
Invalid (DependencyKind r/o) • This will be the result of a property query if the current connection is an invalid dependency kind.
StartFinish* (DependencyKind r/o) • With Start to Finish, once the first task starts, the second one can finish; the tasks must overlap at least at the instant the first one starts.
StartStart* (DependencyKind r/o) • With Start to Start, once the first task has started, the second one can start; the tasks may overlap.
all (Array of DependencyKind r/o) • An array of all items of this enumeration.

Creating Dependencies
Here is a script example demonstrating the establishment of a dependency between two newly created tasks. In this example, the dependent task is set to begin after the prerequisite task has completed.
Create Dependent Pair of Tasks
var task1 = actual.rootTask.addSubtask()
task1.title = "Prerequisite"
var task2 = actual.rootTask.addSubtask()
task2.title = "Dependent"
var dependency = task1.addDependent(task2)
dependency.kind = DependencyKind.FinishStart
1 The first task is created by executing the addSubtask() method on the rootTask object of the base scenario. The resulting reference to the created task object is stored in the variable: task1
2 The created task is assigned the title “Prerequisite”
3 A second task is created by executing the addSubtask() method on the rootTask object of the base scenario. The resulting reference to the created task object is stored in the variable: task2
4 The second created task is assigned the title “Dependent”
5 A dependency is added to the first created task by executing the addDependent(…) method with the first task instance, passing in the stored reference to the second created task (task2) as the direct parameter of the function. The resulting reference to the new dependency object is stored in the variable: dependency
6 The new dependency is assigned a dependency type by setting the value of its kind property to the one that indicates that the dependency begins at the finish or the first task and ends at the beginning of the second task. In terms of the dependency kind class, the type is: DependencyKind.FinishStart
Here is the result of the execution of the example script in the document:

The same result can be achieved with an abbreviated version of the previous script, where tha type of dependency is assigned in the statement in which the dependency is created. (see line 5)
Create Dependent Pair of Tasks
var task1 = actual.rootTask.addSubtask()
task1.title = "Prerequisite"
var task2 = actual.rootTask.addSubtask()
task2.title = "Dependent"
task1.addDependent(task2).kind = DependencyKind.FinishStart
Also note that the same results can be achieved by creating a dependent relationship between the two created tasks using the addPrerequisite(…) function of the Task class called on the second task instance rather than the first task instance. (see line 5)
Create Dependent Pair of Tasks
var task1 = actual.rootTask.addSubtask()
task1.title = "Prerequisite"
var task2 = actual.rootTask.addSubtask()
task2.title = "Dependent"
task2.addPrerequisite(task1).kind = DependencyKind.FinishStart

Clearing All Dependencies
Here’s a script that clears all dependencies from all tasks in the actual scenario.
Clear All Dependencies
actual.rootTask.descendents().forEach(task => {
task.dependents.forEach(dependency => dependency.remove())
})
Add “Lead-Time” to Dependency
Sometimes it is practical to add a delay to a dependency so that non-project related events can occur. For example, say you order new kitchen cabinets for a renovation project. There would be two tasks: “Order the Cabinets”, and “Install the Cabinets”. To allow for the cabinet fabrication and shipping, you would add a “lead-time” duration (perhaps 12 days) to the task dependency object.
Adding “Lead-Time”
var task1 = actual.rootTask.addSubtask()
task1.title = "Order Cabinets"
var task2 = actual.rootTask.addSubtask()
task2.title = "Install Cabinets"
var dependency = task1.addDependent(task2)
dependency.kind = DependencyKind.FinishStart
dependency.leadTimeDuration = Duration.elapsedDays(12)

Group Task with Dependent Subtasks
Here are some script examples demonstrating how to create a group task whose subtasks have dependent relationships.
Task Group with Sequential Subtasks
var groupTitle = "Home Exterior Maintenance"
var jobTitles = ["rake leaves","mow lawn","clean gutters","trim hedges"]
var groupTask = actual.rootTask.addSubtask()
groupTask.title = groupTitle
groupTask.type = TaskType.group
var subTasks = new Array()
jobTitles.forEach((jobTitle,index) => {
var task = groupTask.addSubtask()
task.title = jobTitle
subTasks.push(task)
if(index > 0){
dependency = task.addPrerequisite(subTasks[index-1])
dependency.kind = DependencyKind.FinishStart
}
})

01 Store the name for the task group in the variable: groupTitle
02 Store the titles for the subtasks in the variable: jobTitles
03 Create a new top-level task and stored the resulting object reference in the variable: groupTask
04 Assign the stored group task name to the created task.
05 Set the value of the type property of the created task to TaskType.group
06 Instantiate the variable subTasks to contain an empty array that will hold object references to the created subtasks.
07-15 Use the JavaScript forEach(…) function to iterate the list of subtask titles. Note that the passed parameters for the callback function will include a reference to the title and its position (index) in the array of titles.
08 Call the addSubtask() function on the group task object to add a new subtask to it.
09 Set the title of the created subtask to the iterated title.
10 Add the object reference of the created subtask to the array of subtasks.
11-14 If the created subtask is not the first one, add a prerequisite dependency to the previous subtask.
13 Set the value of the kind property of the dependency to the desired type, which in this case is: DependencyKind.FinishStart
By changing the value of the dependency’s kind property (line 13) to DependencyKind.StartStart the subtasks can be set to run a concurrent (simultaneous) manner:
