An Item represents a database item. Every Item must have at least a category. If it has an id, then it was retrieved from the database and may be altered and later saved (use needsSave() to determine if the Item needs saving). If it doesn't have an id, it needs to be saved. When an item is saved, it's data is re-initialized from the database.

Hierarchy

Constructors

Properties

category: Category
creationDate: string
dirty: boolean
downLinks: IReference[]
fieldMap: Map<number, Field>
fieldMask: ItemFieldMask
history: IItemHistory[]
id: string
isFolderProperty: boolean
labels: string[]
maxVersion: number
title: string
toBeIntegrated: IItemGet
type: string
upLinks: IReference[]

Methods

  • Add a new downlink to the item. Does nothing if the item is already represented

    Parameters

    • id: string

      the id of the item to add.

    • Optional title: string

      optional. The title is just for convenience. It is neither saved nor representative of the actual title of the item.

    Returns Item

    the Item

    Throws

    Error if the passed id matches the id of the current item.

  • Add a new uplink to the item. Does nothing if the item is already represented

    Parameters

    • id: string

      the id of the item to add.

    • Optional title: string

      optional. The title is just for convenience. It is neither saved nor representative of the actual title of the item.

    Returns Item

    the Item

    Throws

    Error if the passed id matches the id of the current item.

  • Create a Todo attached to this item.

    Parameters

    • users: string[]

      an array of user names

    • type: TodoTypes
    • text: string
    • atDate: Date

    Returns Promise<string>

    A comma-separated list of Todo ids (integers), relative to the Item.

  • Sometimes you've been given an Item with a restrictive ItemFieldMask, however, you'd like to set a value for a field that was not in the mask. With this method, you can expand the field mask to include the field given by the fieldId (easily obtained from the Category object).

    This field will be added to the mask, and the associated Field object will be returned with an empty value, which you could set. The object will be marked as "dirty" at this point, because we don't know if the server has an empty value for this field or not, so we assume the pessimistic case.

    Parameters

    • fieldId: number

      a valid fieldId from the Category of the item.

    Returns Field

    the Field object

    Throws

    if the fieldId is already in the ItemFieldMask, or if the fieldId is not valid for the Category.

  • Get the creation date of the item

    Returns string

    a string date value or undefined

  • Returns all fields within the mask which match the fieldName.

    Parameters

    • fieldName: string

    Returns Field[]

    an array of Fields. Note that if the mask has limited the set of fields from the Category which are tracked for this particular item, the number of returned Field objects may be less than you expect.

  • Gets the ItemFieldMask which specifies which fields are loaded

    Returns ItemFieldMask

    on ItemFieldMask object

  • Returns all fields within the mask which match the fieldType.

    Parameters

    • fieldType: string

    Returns Field[]

    an array of Fields. Note that if the mask has limited the set of fields from the Category which are tracked for this particular item, the number of returned Field objects may be less than you expect.

  • Get the unique Id of the Item within the Project.

    Returns string

    a string value containing the Item Id.

  • Returns an array of labels set for the Item.

    Returns string[]

    array of strings

  • Read-only.

    Returns number

    The highest version reached for this item, or undefined if the item hasn't yet been saved on the server.

  • Returns a Field matching the field name. The field should exist and be within the mask.

    Parameters

    • fieldName: string

    Returns Field

    a valid Field.

    Throws

    Error if there is no such field, either because the name is invalid or it is not within the mask for the Item.

  • Return the Todos associated with this item.

    Parameters

    • Optional includeDone: boolean

      if true, includes done todos

    • Optional includeAllUsers: boolean

      if true, includes all todos for all users.

    • Optional includeFuture: boolean

      false by default. If true, includes future todos.

    Returns Promise<GetTodosAck>

    Information on the Todos

  • An Item can be complete or partial, based on the ItemFieldMask passed in at construction.

    Returns boolean

    true if the item has all of its Category fields.

  • Check if there is a downlink to another item

    Parameters

    • id: string

    Returns boolean

    true if this item links to the item given by {id}

  • In case the Item is masked (hasAllFields() returns false), one or more Fields may not be tracked. hasFieldId() allows you to check if the field is present.

    Parameters

    • fieldId: number

      a valid field id within the Category

    Returns boolean

    true if the Item's mask allows for this field.

    Throws

    Error if fieldId is not valid within the Category

  • Check if there is an uplink to another item

    Parameters

    • id: string

    Returns boolean

    true if this item links to the item given by {id}

  • isFolder returns true if the Item is of Category FOLDER.

    Returns boolean

    true if a FOLDER, false otherwise

  • Helper method to test if a field id is valid within the Item Category, irrespective of whether or not it is specified in the mask.

    Parameters

    • fieldId: number

    Returns boolean

    true if fieldId is valid within the Category.

  • needsSave() checks the Fields of the Category to which the Item belongs to see if they've been changed. If so it marks the Item as dirty.

    Returns boolean

    true if the Item has changes that should be propped to the server

  • Remove a link given by {id} if it exists.

    Parameters

    • id: string

      the id of the downlinked item to remove

    Returns Item

    the current Item

  • Remove a link given by {id} if it exists.

    Parameters

    • id: string

      the id of the uplinked item to remove

    Returns Item

    the current Item

  • Initializes the data fields for the item from an IItemGet structure

    Parameters

    Returns void

  • Adds one label to the item if it isn't already set. Note that if the label is in an XOR group with another set label, that label will be removed.

    Parameters

    • labelToSet: string

    Returns Item

    Item

    Throws

    throws error if the Item category doesn't allow labels

  • Sets the labels for an Item, overwriting any previous labels

    Parameters

    • newLabels: string[]

    Returns Item

    Item

    Throws

    throws error if the Item category doesn't allow labels

  • Visit the server and get this Item as a DocItem.

    Returns Promise<DocItem>

    a DocItem.

    Throws

    Error if the fields of this Item are dirty.

  • Unsets one label if it exists.

    Parameters

    • labelToUnset: string

    Returns Item

    Item

    Throws

    throws error if the Item category doesn't allow labels

Generated using TypeDoc