Items

The item type simplifies programming because it allows you to manipulate all the primary Schedule+ objects in the same way. For example, an Appointment item is manipulated in the same way as a Task item because all items support the same properties and methods. The only difference is that you specify different sets of properties when dealing with different objects. For example, properties defined on an Appointment item include Start and OwnerName. In contrast, properties defined on a Task item include Billing, Mileage, Priority, and TaskSource.

All items have the following data members.

Data Member Description
Application Returns an Application object.
Parent Returns to an object’s parent.
Properties Returns the number of properties defined for an object.

All items have the following methods.

Method Description
DeleteProperties Deletes a specified property.
Flush Removes properties that have been changed.
GetProperties Gets the value of one or more specified properties.
GetProperty Gets the value of a specified property for Visual Basic version 3.0.
SetProperties Sets the value of one or more properties.

The following sample code illustrates how to create a new item in the Contacts table and manipulate its properties:

Sub CreateContact()
    Dim objTable As Object, objItem As Object
    
    'Get the Contacts table from the global Schedule object.
    Set objTable = gobjSchedule.Contacts
    
    'Create a new item in the Contacts table.
    Set objItem = objTable.New
    
    'Set the desired properties on the item.
    objItem.SetProperties FirstName:="First", LastName:="Last", _
        Notes:="Notes", _
        PhoneBusiness:="206-555-1212", _
        PhoneFax:="206-93-MS-FAX"
    
    'Release the objects.
    Set objItem = Nothing
    Set objTable = Nothing
End Sub
 

Some items in one table can be associated with items in another. For example, each Task item has a ProjectItemId property that identifies the Project item to which the task is related. Similarly, a Contact item can be associated with a project or a task. These relationships are frequently used by the Schedule+ user interface, but are not required. For example, it is not necessary to associate a Contact item with any other item in any other table.

The following sample code shows how to establish a relationship between a task and a project. It relates the first task in the Tasks table to the first project in the Projects table.

Dim objApp As Object, objSchedule As Object
Dim objProjects As Object, objTasks As Object
Dim objMyTask As Object, objMyProj As Object

‘Retrieve the Schedule object for the topmost open schedule.
Set objSchedule = objApp.ScheduleSelected

Set objProjects = objSchedule.Projects ‘Get the Projects table.
Set objTasks = objSchedule.Tasks       'Get the Tasks table.
Set objMyTask = objTasks.Item          ‘Get first item in Tasks table.
Set objMyProj = objProjects.Item       ‘Get first item in Projects table.
objMyTask.ProjectItemId = objMyProj.ItemId
 

Item relationships enable you to retrieve sets of associated items, such as all tasks associated with a particular project. To do this in your code, you can set a restriction on the Task table and Schedule+ will return only those tasks that meet the restriction. You can also loop through all Task items and find those with a specific ProjectItemId property.