Properties and values

View as Markdown

The metadata of an object version is a list of property values. Each one pairs a property definition ID with a typed value:

PropertyValue
  property_def: 1002                       property definition ID ("Document date")
  value: TypedValue
    type: DATATYPE_DATE                    must match PropertyDef.data_type
    is_null_value: false                   true = empty value; data is then unset
    data: TypedValueUnion { date: ... }    exactly one member, the one that matches type

Data types

Data type Union member Example property (Sample Vault) Notes
DATATYPE_TEXT text 0 Name or title, 1004 Keywords at most 100 characters; longer text is cut to 100 without an error
DATATYPE_MULTI_LINE_TEXT multi_line_text 33 Comment, 1034 Description long text; \n line breaks are kept
DATATYPE_INTEGER integer 1103 Proposal number 32-bit
DATATYPE_REAL_NUMBER real_number (none in the Sample Vault) double
DATATYPE_DATE date 1002 Document date a Timestamp at midnight UTC; a time of day is dropped
DATATYPE_TIMESTAMP timestamp 20 Created, 21 Last modified UTC Timestamp
DATATYPE_BOOLEAN boolean 22 Single file, 1098 Accepted
DATATYPE_LOOKUP lookup 100 Class, 39 Workflow State, 1143 Agreement type one item or object
DATATYPE_MULTI_SELECT_LOOKUP multi_select_lookup 1079 Customer, 101 Class groups any number of items or objects

Datatype lists more types, such as DATATYPE_TIME; the Sample Vault has no properties of them. By their descriptions, DATATYPE_INTEGER64 and DATATYPE_FILETIME are not used in document properties.

The 100-character limit is easy to miss: the server stores the first 100 characters of a longer single-line text and reports success. Use a multi-line text property for longer values.

Empty values

An empty value keeps its type: type set, is_null_value true, data unset. The server returns empty properties the same way, for example 1034 Description on an object without a description:

property_def: 1034  value { type: DATATYPE_MULTI_LINE_TEXT  is_null_value: true }

Send the same shape to empty a property. Removing a property from the object entirely is a different operation (remove in SetPropertiesRequest). It works only for properties that the class does not list: removing one that it lists fails with 'The property "Keywords" cannot be removed from the object.' A property that the class lists is present on the object even when nobody set it, as an empty value.

Lookups

A lookup value points to a value list item or an object. To set one, only the IDs are needed:

property_def: 1143                          Agreement type (lookup to value list 160)
value {
  type: DATATYPE_LOOKUP
  data { lookup { value_list_item_info { obj_id { type: 160  item_id { internal_id: 2 } } } } }
}

Rules the server applies

Writing values

Task Call
Create an object with values AddObject (properties)
Change values SetProperties (properties, remove)
Change values when checking in CheckIn (properties)
Read values GetProperties, GetObjectVersionAndPropertiesOfMultipleObjects

SetProperties changes only the properties you send, unless remove_unspecified_properties is true: then every property not in the request is removed. Leave it false unless you send the complete set.

Methods whose names end in WithMetadata use PropertyValueWithMetadata instead, which adds value_metadata (who or what set the value, such as a user or AI, and why). The plain PropertyValue methods above do not need it.