Projects
A Project represents the main contents of an OmniPlan Document and is used as the global object in any scripting session that is related to a particular document.
Instance Properties
Here are the instance properties of the Project class:
actual (Scenario r/o) • The scenario containing actual values for all tasks and resources, as opposed to baselines.
baselineNames (Array of String r/o) • Names of all of the baseline scenarios.
document (PlanDocument or null) • The hosting OmniPlan document.
title (String) • Title of this project.
A Project represents the contents of an OmniPlan document, and when writing scripts that target the content of the current document, the project becomes the topmost object, providing properties whose values are references to the scenarios (actual and baselines) the project contains.
In the following example, all three syntax variations are valid, but in practice, the sole property name “actual” is commonly used to represent the current instance of the Scenario class:
The “actual” Property
document.project.actual
//--> [object Scenario]
// The Project is the topmost object and can be referenced using the “this” keyword
this.actual
06//--> [object Scenario]
// Since the Project is the top-level item, it is implied and so you can simply use the property name
actual
//--> [object Scenario]
The same applies to the “title” property as well:
The “title” Property
document.project.title
//--> "90-Day Blank Project"
// The Project is the topmost object and can be referenced using the “this” keyword
this.title
//--> "90-Day Blank Project"
// Since the Project is the top-level item, it is implied and so you can simply use the property name
title
//--> "90-Day Blank Project"
Instance Functions
Here are the functions that can be called on an instance of the Project class:
baselineNamed(name:String) → (Scenario or null) • Load the given named baseline scenario, if necessary, and return it.
As with project properties, the use of project functions may assume the top-level status of the Project class, and be entered without preface:
Target a Baseline
var targetScenario = baselineNamed("Alternate Baseline")
if(targetScenario){
// processing statements go here
}
Instances of the Project, Resource, and Task classes may optionally have metadata keys and values associated with them. Use the following functions to set and retrieve the metadata:
customValue(forKey: String) → (String or null) • Access to custom data values.
setCustomValue(forKey: String, to: String) → ( ) • Change custom data values.
Set and Retrieve Project Metadata
setCustomValue("Manager", "Wanda Gardener")
customValue("Manager")
//--> "Wanda Gardener"
setCustomValue("Contact", "w.gardener@acme.com")
customValue("Contact")
//--> "w.gardener@acme.com"
Metadata for the project can be viewed and edited in the project inspector pane:
