API Reference

Objects

Objects

findObjects

Search for objects matching various input criteria

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
TypeStringThe type of objects searched for. Check getSpecialTypes
ExactSearchFieldsFieldValue[]Array of fields and search criteria. Use for category fields and boolean fields only. Check getFieldDefs
GeneralSearchFieldsString[]Fields that should be used for free text search. Use fields that are searchable. Check getFieldDefs
GeneralSearchStringStringSearch string to use on GeneralSearchFields
ActiveBooleanIf the search should only return active objects
ReservedBooleanIf the search should only return objects the user has sufficient permissions to reserve
SortOrderStringThe sorting order for the objects matching the query. Check getObjectStortOrders
ReturnFieldsString[]The fields to include on the objects matching the query. To get a list of applicable fields for the type use getAllFields. Only fields that are listable can be used. This can be determined by examining the fields with getFieldDefs. The first return field must also be sortable if the objects are sorted by the return fields.
BeginIndexIntIndex of the first object to return (for pagination)
NumberOfObjectsIntMaximum number of objects to return (capped at 1000 per query, use BeginIndex to paginate over the objects). Check getLimitations

Returns

ReturnTypeDescription
ObjectsObject[]Array of all objects matching the query, with the fields specified in ReturnFields
TotalNumOfObjectsIntTotal number of objects matching the query

Example

Request

<tns:type>room</tns:type>
<tns:exactsearchfields>
  <field>
    <extid>room.type</extid>
    <value>Lecture</value>
  </field>
</tns:exactsearchfields>
<tns:generalsearchfields>
  <field>room.name</field>
</tns:generalsearchfields>
<tns:generalsearchstring>b</tns:generalsearchstring>
<tns:active>false</tns:active>
<tns:reserved>true</tns:reserved>
<tns:sortorder>MODIFIED_DESCENDING</tns:sortorder>
<tns:returnfields>
  <field>room.name</field>
  <field>room.number_of_seats</field>
  <field>room.type</field>
</tns:returnfields>
<tns:beginindex>0</tns:beginindex>
<tns:numberofobjects>1000</tns:numberofobjects>

findObjectsExtended

Extended object search function. Note that the parameters may behave a bit differently than for findObjects.

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
TypeStringThe type of the objects to search for Check getSpecialTypes
ExactSearchFieldsFieldValue[]Array of fields and search criteria. Only for use with category fields and boolean fields only. Check getFieldDefs
GeneralSearchFieldsString[]Fields that should be used for free text search. Use fields that are searchable. Check getFieldDefs
GeneralSearchStringStringSearch string together with GeneralSearchFields
ActiveBooleanSkip or leave empty for both active and inactive objects, true for active objects only or false for inactive objects only
VirtualBooleanSkip or leave empty for both virtual and non-virtual objects, true for virtual objects only or false for non-virtual objects only
AbstractBooleanSkip or leave empty for both abstract and non-abstract objects, true for abstract objects only or false for non-abstract objects only
ReservableBooleanSkip or false for all readable objects or true for all objects that can be reserved
SortOrderStringThe sorting order for the objects matching the query. Check getObjectStortOrders
ReturnFieldsString[]The fields to include on the objects matching the query. To get a list of applicable fields for the type use getAllFields. Only fields that are listable can be used. This can be determined by examining the fields with getFieldDefs. The first return field must also be sortable if the objects are sorted by the return fields.
RelatedObjectTypesString[]Get related objects with the selected types. If the search is made for course related types could for instance be teacher
OptionalRelatedObjectTypesString[]Get optional related objects with the selected types. If the search is made for class, optional related types could for instance be course
BeginModifiediCalTimeStringFind objects modified from, including this time stamp. See also Time Stamps
EndModifiediCalTimeStringFind objects modified to, excluding this time stamp. See also BeginModified
ObjectsString[]If set only the objects with the specified external ids will be returned
BeginIndexIntIndex of the first object to return starting at 0 (for pagination)
NumberOfObjectsIntMaximum number of objects to return (capped at 1000 per query, use BeginIndex to paginate over the objects). Check getLimitations

Returns

ReturnTypeDescription
ObjectsObject[]Array of all objects matching the query, with the fields specified in ReturnFields
TotalNumOfObjectsIntTotal number of objects matching the query

Example

Request

<tns:type>course</tns:type>
<tns:exactsearchfields>
    <field>
        <extid>course.subject</extid>
        <value>Economics</value>
    </field>
</tns:exactsearchfields>
<tns:generalsearchfields></tns:generalsearchfields>
<tns:generalsearchstring></tns:generalsearchstring>
<tns:active>true</tns:active>
<tns:abstract>false</tns:abstract>
<tns:virtual>false</tns:virtual>
<tns:sortorder>RETURNFIELDS_ASCENDING</tns:sortorder>
<tns:returnfields>
    <field>course.id</field>
</tns:returnfields>
<tns:relatedobjecttypes>
    <type>teacher</type>
</tns:relatedobjecttypes>
<tns:beginmodified>20210101T000000</tns:beginmodified>
<tns:endmodified>20210201T000000</tns:endmodified>
<tns:beginindex>0</tns:beginindex>
<tns:numberofobjects>1000</tns:numberofobjects>

getObjects

Get objects from external ids

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
ObjectsString[]Array of external ids of the objects

Returns

ReturnTypeDescription
ObjectsObject[]Array of all requested objects

Example

Request

<tns:objects>
  <object>238584c4-1833-48bd-b7be-2c15529bbb62</object>
</tns:objects>

getObjectsWithFieldValues

Get objects based on field values

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
TypeStringThe type of object searched for
FieldStringThe field to base the search on
UniquefieldvaluesString[]Array of accepted field values

Returns

ReturnTypeDescription
ObjectsObject[]Array of all objects matching the query

Example

Request

<tns:type>staff</tns:type>
<tns:field>staff.shortname</tns:field>
<tns:uniquefieldvalues>JS</tns:uniquefieldvalues>
<tns:uniquefieldvalues>GH</tns:uniquefieldvalues>

inactivateObjects

Inactivate objects of a certain type and modified before a certain timestamp

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
TypeStringThe type of object to inactivate
ModifiedBeforeStringMilleniumDateTime string

Returns

ReturnTypeDescription
ObjectsObject[]Array of all inactivated objects

Example

Request

<tns:types>course</tns:types>
<tns:modifiedbefore>20190801T000000</tns:modifiedbefore>

getObjectSortOrders

Inactivate objects of a certain type and modified before a certain timestamp

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key

Returns

ReturnTypeDescription
SortOrdersString[]Available sort orders for objects

Example

Request

-

newObject

Get the data structure for what a new object of a specified type should look like

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
TypesString[]Types of the object the data structure template is being requested for

Returns

ReturnTypeDescription
ObjectObjectData structure template for a new object of the requested types

Example

Request

<tns:types>
  <type>course</type>
</tns:types>

validateObjects

Get the data structure for what a new object of a specified type should look like

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
ObjectsObject[]Array of objects to be validated
ModeStringValidation mode, "Replace", "Add", "Update" or "Ignore" are valid values. If omitted, "Replace" will be used

Returns

ReturnTypeDescription
StatusStatus[]Array of validation status per object. A status of 0 indicates the object passed validation

Example

Request

<tns:objects>
    <object>
        <extid>d2afc6a3-6028-4b2e-969b-a4daabacbf84</extid>
        <fields>
            <field>
                <extid>room.name</extid>
                <value>Pacific</value>
            </field>
            <field>
                <extid>room.type</extid>
                <value>Mötesrum</value>
            </field>
            <field>
                <extid>room.equipment</extid>
                <value>Whiteboard</value>
            </field>
            <field>
                <extid>room.number_of_seats</extid>
                <value>8</value>
            </field>
            <field>
                <extid>general.description</extid>
                <value>Stora rummet vid ingången</value>
            </field>
            <field>
                <extid>room.map</extid>
                <value>https://drive.google.com/a/timeedit.com/file/d/19SHPlmVYkSFajzjJib0DRFGGIze6S5eI/view?usp=sharing</value>
            </field>
        </fields>
        <created>20181217T131707</created>
        <modified>20190318T083511</modified>
        <createdby>
            <loginname>admin</loginname>
            <authserver>timeedit</authserver>
        </createdby>
        <modifiedby>
            <loginname>admin</loginname>
            <authserver>timeedit</authserver>
        </modifiedby>
        <organizations>
            <organization>admin</organization>
        </organizations>
        <types>
            <type>room</type>
            <type>ongoing_work</type>
            <type>ongoing_rooms</type>
        </types>
        <active>true</active>
        <virtual>false</virtual>
        <isAbstract>false</isAbstract>
    </object>
</tns:objects>
<tns:mode>update</tns:mode>

importObjects

Import objects to the database.

Object import modes

When importing objects, the attribute mode can be specified at several points in the XML description of the object. The mode attribute enables fine-grained control over how TimeEdit adds, overwrites or ignores imported information should the object already exist.

Locations

The mode attribute can be specified on the object tag itself and on the types, the fields, members, the related and the organizations lists. Individual fields may also have a mode attribute specified.
Modes are inherited through the object. Thus, the mode on the object itself is the default and is used whenever another mode has not been specified.
The default mode, used when an object does not specify otherwise, is replace. However, the API calls for importing and validating objects also permit specifying a global mode as a parameter. If provided, this mode will be applied to all objects which do not specify a different mode themselves.

Values

The four basic mode values are add, update, replace and ignore.

Ignore means that the element will not be imported if the object exists and already contains such an element. For example, if three members are listed in the XML and the mode is set to "ignore" these three members will not be imported if the object already exists and has any members set.

Add simply adds the information from the XML to any existing object. The three member objects would be added to the existing object alongside any already set members.

Replace, similarly, simply replaces whatever objects may appear in any existing object. So, after importing the above mentioned three members the object would have those three members and no others, regardless of which members the object may have had prior to the import.

Update, technically works as a mixture between the other three modes. Everything except fields is treated as if the specified mode was add, while fields will be treated as if replace was specified. Also, fields not specified will be treated as if ignore was specified, and thus remain unchanged.

For members and related, a list of types may be specified instead of add, update, replace or ignore. The types are specified using their external ID, multiple types are separated by a semicolon. Unless the mode is exactly add, update, replace or ignore, it will be interpreted as a list of one or more types. Specifying a type indicates that only objects of this type should be modified while others are ignored. Thus, an import can specify that it only changes an object's list of related rooms by specifying mode="Room" on the related tag. The object's related rooms will be set to the ones listed in the XML document, while any other related objects will be left untouched.
All fields not specified will be added without values. It is worth noting that if replace is specified on the fields list, any fields not listed in the XML document will be replaced with empty values (thus having any already set value removed).

More information

For more information on possible values see also

getAvailabilityRelationKinds

getObjectColors

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
ObjectsObject[]Array of objects to import
ModeStringImport mode, Replace, Add, Update or Ignore are valid values. If omitted, Replace will be used

Returns

ReturnTypeDescription
StatusStatus[]Array of import status per object. A status of 0 indicates the object was imported successfully

Example

Request

<tns:objects>
    <object mode="replace">
        <extid>class_science_2</extid>
        <fields mode="replace">
            <field mode="replace">
                <extid>class.name</extid>
                <value>Science 2</value>
            </field>
            <field mode="replace">
                <extid>class.year</extid>
                <value>2019</value>
            </field>
            <field mode="replace">
                <extid>group.frequency</extid>
                <value>Annual</value>
            </field>
            <field mode="replace">
                <extid>class.email</extid>
                <value>[email protected]</value>
                <value>[email protected]</value>
            </field>
            <field mode="ignore">
                <extid>general.description</extid>
                <value>This class is a group that occur annually</value>
            </field>
        </fields>
        <organizations mode="add">
            <organization>some_department</organization>
            <organization>some_other_department</organization>
        </organizations>
        <members mode="student">
          <object>student_1234567890</object>
          <object>student_2480248024</object>
        </members>
        <types mode="add">
            <type>class</type>
            <type>group</type>
        </types>
        <related mode="replace">
          <object>course_ABC123</object>
          <object>course_DEF456</object>
          <objects>
            <object>teacher_1234567890</object>
            <object>activity_lecture</object>
          </objects>
          <objects>
            <object>teacher_1234567891</object>
            <object>activity_seminar</object>
          </objects>
        </related>
        <optionalrelated mode="replace">
          <object>course_ABC123</object>
        </optionalrelated>
        <availabilityrelated kind="Classgroups" mode="ignore">
          <object>classgroup_1234567890</object>
        </availabilityrelated>
        <active>true</active>
        <virtual>false</virtual>
        <isAbstract>false</isAbstract>
        <color>Green striped</color>
    </object>
</tns:objects>
<tns:mode>update</tns:mode>

exportObjects

Export objects (e.g., for syncing object data with other systems or 3rd party applications)

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
ObjectsString[]Array of external ids for objects to export
IncludeRelationTimesBoolInclude time information for members and relational objects in the export

Returns

ReturnTypeDescription
ObjectsObject[]Complete export of the requested objects

Example

Request

<tns:objects>
  <object>3d379d07-5269-45d3-9b77-18d15de75650</object>
  <object>fa55f47c-a67b-4742-9c8a-099df5d1782d</object>
</tns:objects>
<tns:includerelationtimes>false</tns:includerelationtimes>

deleteObjects

Delete specific objects. If an object can't be deleted, for example because the object is reserved, there is an option to inactivate the object. Note that the functions tries to delete the object, but if this fails for some reason, it may try to inactivate the object instead depending on the parameters

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
ObjectsString[]Array of external ids for objects to delete or inactivate
InactivateBoolIf an object can't be deleted, setting this option to true, will try to inactivate the object

Returns

ReturnTypeDescription
StatusStatus[]The result of the deletion, one for each object

Example

Request

<tns:objects>
  <object>c1e3b417-9535-47fa-9a4a-076b2d7f2dea</object>
  <object>281fc32a-c64f-4580-bf9c-eb7afee7a36f</object>
</tns:objects>
<tns:inactivate>false</tns:inactivate>

getAvailabilityRelationKinds

Get the different availability relations used when importing objects.

The values of this function can be used as attribute mode on the tag availabilityrelated.

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key

Returns

ReturnTypeDescription
AvailabilityRelationKindsAvailabilityRelationKind[]List of availability relation types

Example

Request

-

getObjectColors

Get the available object colors that can be used when importing objects.

The result of this function are the colors that can be used as values for the tag color in importObjects and exportObjects. Colors are represented by a string with the name of the color. The empty string represents objects with no color. Note that the names of colors reoccur with different patterns.

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key

Returns

ReturnTypeDescription
colorscolor[]List of available object colors

Example

Function response from July 31, 2020

<colors>
    <color>Green</color>
    <color>Yellow</color>
    <color>Blue</color>
    <color>Purple</color>
    <color>Mint green</color>
    <color>Orange</color>
    <color>Red</color>
    <color>Light blue</color>
    <color>Dark yellow</color>
    <color>Pink</color>
    <color>Lime green</color>
    <color>Army green</color>
    <color>Wine red</color>
    <color>Acid green</color>
    <color>Orchid purple</color>
    <color>Brown</color>
    <color>Green striped</color>
    <color>Yellow striped</color>
    <color>Blue striped</color>
    <color>Purple striped</color>
    <color>Mint green striped</color>
    <color>Orange striped</color>
    <color>Red striped</color>
    <color>Light blue striped</color>
    <color>Dark yellow striped</color>
    <color>Pink striped</color>
    <color>Lime green striped</color>
    <color>Army green striped</color>
    <color>Wine red striped</color>
    <color>Acid green striped</color>
    <color>Orchid purple striped</color>
    <color>Brown striped</color>
</colors>

findObjectFields

Get which object fields an object can have depending on the object type

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
TypesString[]The types of the object in question

Returns

ReturnTypeDescription
FieldsField[]List of fields that may exist on the object in question

Example

Request

-

findFreeObjects

Find objects that are not occupied at a certain date and time and can be reserved by the current user

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
begintimeiCalTimeStringThe begin time where objects are to be free. Check getCurrentDateTime
endtimeiCalTimeStringThe end time where objects are to be free
typeStringThe type of the object to find
exactsearchfieldsFieldSearch[]Categories that the objects should have
generalsearchfieldsField[]Other fields that the objects should match together with generalsearchstring
generalsearchstringStringThe search value for generalsearchfields
numberofobjectsIntThe maximum number of objects to return, default value is 10
sortorderStringHow the objects should be sorted, see also getObjectSortOrders
returnfieldsField[]The fields to return for the object
reservationsituationStringThe reservation mode to use when finding free time, see also getReservationSituations

Returns

ReturnTypeDescription
ObjectsObject[]Objects that are free the specified time

Example

Request

-

findFreeObjectsOtherUser

Find objects that are not occupied at a certain date and time and can be reserved by another user

Parameters

ParameterTypeDescription
LoginLoginObjectStandard login object with username, password, and application key
begintimeiCalTimeStringThe begin time where objects are to be free. Check getCurrentDateTime
endtimeiCalTimeStringThe end time where objects are to be free
typeStringThe type of the object to find
exactsearchfieldsFieldSearch[]Categories that the objects should have
generalsearchfieldsField[]Other fields that the objects should match together with generalsearchstring
generalsearchstringStringThe search value for generalsearchfields
numberofobjectsIntThe maximum number of objects to return, default value is 10
sortorderStringHow the objects should be sorted, see also getObjectSortOrders
returnfieldsField[]The fields to return for the object
reservationsituationStringThe reservation mode to use when finding free time, see also getReservationSituations
userStringThe user that is to able to reserve the objects

Returns

ReturnTypeDescription
ObjectsObject[]Objects that are free the specified time

Example

Request

-