Ref interface

A JavaScript object implementing the Ref interface is a reference to an object in the Object Store.

Construction

Use O.ref().

To avoid hardcoding Ref values in your plugin, use the behaviour lookup functions.

If you have an array of Ref objects, the O.deduplicateArrayOfRefs() function may be useful.

Interface

property objId

The object ID of the object.

function toString()

Return the reference in ‘presentation’ format, used in URLs and XML.

function load()

Load the referred object, returning an object implementing the JavaScript interface StoreObject.

Note that deleted objects can still be loaded. Use the deleted property if checking that object hasn’t been deleted is important. However, in many cases, you should just use it anyway.

function loadVersion(version)

Load the specified version of the referred object, returning a StoreObject.

function loadVersionAtTime(date)

Load the version of the referred object which was the current version at the specified date, returning a StoreObject.

function loadObjectTitleMaybe()

Returns the title of the referred object as a String. If the Ref refers to an object which doesn’t exist, or the current user does not have permission to read, null is returned.

function deleteObject()

Deletes the object referred to by this reference, without loading it first. Has the same effect as the deleteObject function on a StoreObject, but more efficient if the object has not already been loaded.

property behaviour

Returns the ‘behaviour’ of the object represented by this Ref. See Behaviours for how this property is determined and the intended use.

If the object does not have a behaviour, this property is null.

The current user’s permissions are not enforced when reading the object store to determine the behaviour.

function getBehaviourExactMaybe()

Returns the exact configured behaviour attribute of the object, without using the inheritance rules of the behaviour property.

If there is no attribute, null will be returned.

It is a function, rather than a property, because it will do a database lookup every time it’s called. You need to be careful about performance when using it.

Also, in general, a good design should never need to test what the exact behaviour is, only the root behaviour. If you need this, then there’s something exceptional going on, and your code should look ugly to warn everyone reading it in the future.

The current user’s permissions are not enforced when reading the object store to determine the behaviour.