×

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.

Instance Functions

The functions that may be applied to an instance of a dependency.

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.

dependency-types

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.

omniplan://localhost/omnijs-run?script=try%7Btask1%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask1%2Etitle%20%3D%20%22Prerequisite%22%0Atask2%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask2%2Etitle%20%3D%20%22Dependent%22%0Adependency%20%3D%20task1%2EaddDependent%28task2%29%0Adependency%2Ekind%20%3D%20DependencyKind%2EFinishStart%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
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:

dependency-example-01

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)

omniplan://localhost/omnijs-run?script=try%7Btask1%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask1%2Etitle%20%3D%20%22Prerequisite%22%0Atask2%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask2%2Etitle%20%3D%20%22Dependent%22%0Atask1%2EaddDependent%28task2%29%2Ekind%20%3D%20DependencyKind%2EFinishStart%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
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)

omniplan://localhost/omnijs-run?script=try%7Btask1%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask1%2Etitle%20%3D%20%22Prerequisite%22%0Atask2%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask2%2Etitle%20%3D%20%22Dependent%22%0Atask2%2EaddPrerequisite%28task1%29%2Ekind%20%3D%20DependencyKind%2EFinishStart%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
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
dependency-example-01

Clearing All Dependencies

Here’s a script that clears all dependencies from all tasks in the actual scenario.

omniplan://localhost/omnijs-run?script=try%7Bactual%2ErootTask%2Edescendents%28%29%2EforEach%28%28task%29%3D%3E%7B%0A%09task%2Edependents%2EforEach%28%28dependency%29%3D%3E%7Bdependency%2Eremove%28%29%7D%29%0A%7D%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
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.

omniplan://localhost/omnijs-run?script=try%7Btask1%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask1%2Etitle%20%3D%20%22Order%20Cabinets%22%0Atask2%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0Atask2%2Etitle%20%3D%20%22Install%20Cabinets%22%0Adependency%20%3D%20task1%2EaddDependent%28task2%29%0Adependency%2Ekind%20%3D%20DependencyKind%2EFinishStart%0Adependency%2EleadTimeDuration%20%3D%20Duration%2EelapsedDays%2812%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
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)
lead-time-example

Group Task with Dependent Subtasks

Here are some script examples demonstrating how to create a group task whose subtasks have dependent relationships.

omniplan://localhost/omnijs-run?script=try%7BgroupTitle%20%3D%20%22Home%20Exterior%20Maintenance%22%0AjobTitles%20%3D%20%5B%22rake%20leaves%22%2C%22mow%20lawn%22%2C%22clean%20gutters%22%2C%22trim%20hedges%22%5D%0Avar%20groupTask%20%3D%20actual%2ErootTask%2EaddSubtask%28%29%0AgroupTask%2Etitle%20%3D%20groupTitle%0AgroupTask%2Etype%20%3D%20TaskType%2Egroup%0AsubTasks%20%3D%20new%20Array%28%29%0AjobTitles%2EforEach%28%28jobTitle%2Cindex%29%3D%3E%7B%0A%09task%20%3D%20groupTask%2EaddSubtask%28%29%0A%09task%2Etitle%20%3D%20jobTitle%0A%09subTasks%2Epush%28task%29%0A%09if%28index%20%3E%200%29%7B%0A%09%09dependency%20%3D%20task%2EaddPrerequisite%28subTasks%5Bindex%2D1%5D%29%0A%09%09dependency%2Ekind%20%3D%20DependencyKind%2EFinishStart%0A%09%7D%0A%7D%29%7Dcatch%28err%29%7Bconsole%2Elog%28err%29%7D
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 } })
sequential-subtasks

 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:

concurrent-subtasks