Class

Page

Page

CustomEntity representing a cplace Page.

Extends

Methods

exists() → {boolean}

Check, whether the entity referenced by this object exists.

Inherited From:

true if object references an existing entity, false otherwise

boolean
Example
// page is a reference to a custom entity of type page
if (page.exists()) {
  // do something
}

get(internalName, enumsAsDisplayValueopt, enumLanguageopt) → {Object}

Get the current value of a given entity attribute.

Parameters:
Name Type Attributes Default Description
internalName string

the internal name of the attribute. If there is an prefix defined for the containing type this can also be just the suffix.

enumsAsDisplayValue boolean <optional>
false

If given and set to true, for enum attributes the returned value will be the localized display value, otherwise the internal name of the value will be returned. Please note that for localized enum values, the specified language will be used - when no localized value for that language is defined, then no further fallback is done and null is returned

enumLanguage string <optional>

Specifies the language name for the localized enum value. If this is not specified, the current user's language will be used (if run in a context without user session, the tenant's default language is used). If this is specified, the above parameter enumsAsDisplayValue is optional and assumed to be true.

Inherited From:

The current value.

Object
Examples
// page is a reference to a custom entity of type page
var assignee = page.get('assignee'); // Get value of 'assignee' attribute. Will be null if not found or set
if (assignee != null) {
  // do something
}
// assume the configured prefix is 'cf.cplace.example' both calls will be equivalent:
var valueName  = page.get('value');
var valueName2 = page.get('cf.cplace.example.value');
// Attribute 'myEnum' is a text enumeration attribute
var myInternalName = page.get('myEnum');                     // Internal value
var myGermanLocalizedValue = page.get('myEnum', true, 'de'); // Enum value in German
var myOtherGermanValue = page.get('myEnum', 'de');           // Shorter way to get the German value
var myEnglishEnumValue = page.get('myEnum', 'en');           // Enum value in English

// Get the enum value in the current user's language:
var myUserLanguageEnumValue = page.get('myEnum', true);

// Get the enum value in language of a specific user:
var user = cplace.utils().findUserByLogin('user@example.com');
var userLanguage = user ? user.getUserLanguage() : null;
var userLanguageEnumValue = page.get('myEnum', true, userLanguage);

getAttributeDisplayName(internalName) → {string}

Get the localized display name of custom attribute in the language of the current session.

Parameters:
Name Type Description
internalName string

the internal name of the attribute. If there is an prefix defined for the containing type this can also be just the suffix.

Inherited From:

Display name of attribute in current language. Will be null if the attribute is not found

string
Example
// page is a reference to a custom entity of type page
var assignee = page.getAttributeDisplayName('assignee'); // Get display name of attribute 'assignee' in current language

// assume the configured prefix is 'cf.cplace.example' both calls will be equivalent:
var valueName  = page.getAttributeDisplayName('value');
var valueName2 = page.getAttributeDisplayName('cf.cplace.example.value');

getBuiltinFeatureValue(featureName) → {boolean|string|Date|number|ArrayLike.<CustomEntity>}

Get value of a builtin feature.

Parameters:
Name Type Description
featureName string

the name of the builtin feature to get from the entity.

Inherited From:

Current value or null if this object does not refer to an existing entity.

boolean | string | Date | number | ArrayLike.<CustomEntity>
Example
// page is a reference to a custom entity of type page
var createDate = page.getBuiltinFeatureValue('createdAt'); // Get creation date of page

getId() → {string}

Get the Uid of the entity

Inherited From:

The Uid of the entity or null if this object does not refer to an existing entity.

string
Example
// page is a reference to a custom entity of type page
var id = page.getId(); // Get Uid of the page. Will be null if page does not reference an existing entity

getIncomingPages(typeName, attributeShortName, …spaceUids) → {ArrayLike.<Page>}

Get incoming pages, i.e. pages which refer to this page.

Note: if the attribute's type has a defined prefix for internal attribute names the shortName parameter is expected to just be the attribute's shortName. However if there is no name prefix set you have to provide the attribute's full qualified name (internal name) otherwise the result will be empty.

Parameters:
Name Type Attributes Description
typeName string

Name of type definition of the attribute which holds reference to this page

attributeShortName string

Short name of attribute which holds reference to this page

spaceUids string <repeatable>

The Uids of spaces the results should be taken from

Iterable of incoming pages, may be empty

ArrayLike.<Page>
Example
var incomingPages = page.getIncomingPages('my.type', 'pageReferenceAttribute', page.getSpaceId(), anotherPage.getSpaceId());
cplace.each(incomingPages, function(page) {
  cplace.log(page.getName());
});

getIncomingPages(typeName, attributeName) → {ArrayLike.<Page>}

Get incoming pages, i.e. pages which refer to this page. Results will only be taken from this page's space.

Note: if the attribute's type has a defined prefix for internal attribute names the shortName parameter is expected to just be the attribute's shortName. However if there is no name prefix set you have to provide the attribute's full qualified name (internal name) otherwise the result will be empty.

Parameters:
Name Type Description
typeName string

Name of type definition of the attribute which holds reference to this page

attributeName string

Either Short name or full internal name of attribute which holds reference to this page. If short name is used attribute prefix must be set in type settings.

Iterable of incoming pages, may be empty

ArrayLike.<Page>
Example
var incomingPages = page.getIncomingPages('my.type', 'pageReferenceAttribute');
cplace.each(incomingPages, function(page) {
  cplace.log(page.getName());
});

getIncomingPagesFromAllSpaces(typeName, attributeShortName) → {ArrayLike.<Page>}

Get incoming pages, i.e. pages which refer to this page. Results will be taken from all spaces.

Note: if the attribute's type has a defined prefix for internal attribute names the shortName parameter is expected to just be the attribute's shortName. However if there is no name prefix set you have to provide the attribute's full qualified name (internal name) otherwise the result will be empty.

Parameters:
Name Type Description
typeName string

Name of type definition of the attribute which holds reference to this page

attributeShortName string

Short name of attribute which holds reference to this page

Iterable of incoming pages, may be empty

ArrayLike.<Page>
Example
var incomingPages = page.getIncomingPagesFromAllSpaces('my.type', 'pageReferenceAttribute');
cplace.each(incomingPages, function(page) {
  cplace.log(page.getName());
});

getName() → {string}

Get the name of the entity

Inherited From:

name of the entity. null if this object does not refer to an existing entity.

string
Example
// page is a reference to a custom entity of type page
var name = page.getName(); // Get name of the page. Will be null if page does not reference an existing entity

getOptional(internalName) → {Object}

Get the current value of a given entity attribute.

For single reference attributes with a null value, a CustomEntity object of the correct subtype is returned. As that object does not refer to an existing entity, exists will always return false, getter methods will always return false.

Parameters:
Name Type Description
internalName string

the internal name of the attribute. If there is an prefix defined for the containing type this can also be just the suffix.

Inherited From:

Current value of attribute, null if no type or attribute definition for that name is found or a dummy page if the attribute is an unset single reference.

Object
Example
// page is a reference to a custom entity of type page
var assignee = page.getOptional("assignee"); // Get value of 'assignee' attribute
if (assignee.exists()) {                     // Check if assignee is set (i.e. exists)
  // do something
}

// assume the configured prefix is 'cf.cplace.example' both calls will be equivalent:
var valueName  = page.getOptional('value');
var valueName2 = page.getOptional('cf.cplace.example.value');

getParent() → {Page}

Get parent page

Parent page or null if there is no parent or if this object does not refer to an existing entity.

Page
Example
var parentPage = page.getParent();
if (parentPage != null) {
  // Do something
}

getRealUid() → {string}

Get the real Uid of the entity. If this entity is persistent or is a writable copy of a persistent entity, returns the UID built from persistent id of the persistent entity. Otherwise (i.e., if the entity is new) this method returns the UID built from the current id.

Inherited From:

The real Uid of the entity or null if this object does not refer to an existing entity.

string
Example
// page is a reference to a custom entity of type page
var id = page.getRealUid(); // Get real Uid of the page. Will be null if page does not reference an existing entity

getSpaceId() → {string}

Get the Uid of the space of this entity

Uid of space of this entity or null if this wrapped entity does not contain a real entity

string
Example
// Get Uid of the page's space. Will be null if page does not reference an existing entity
var spaceUid = page.getSpaceId();

getUrl() → {string}

Get the absolute URL of the page, usable e.g. to send links in mail

URL of this page or null if this object does not refer to an existing entity.

string
Example
var pageUrl = page.getUrl();
var someMessage = 'Please take a look at the page on ' + pageUrl;

getVersionHistoryOfAttribute(entity, attributeName) → {ArrayLike.<ChangeData>}

Creates the version history of an attribute

Parameters:
Name Type Description
entity CustomEntity

the entity

attributeName string

The internal attribute name

Inherited From:

Version history of an attribute

ArrayLike.<ChangeData>

registerAttributeForRefresh(attributeName)

Register a custom attribute of the page for refresh. Useful e.g. when the value of an attribute is updated in a change listener and should be automatically refreshed in the UI.

Parameters:
Name Type Description
attributeName string

The internal attribute name

Example
// assuming actions are enabled in this context (e.g. in a change listener)
cplace.actions().updatePage(page, { customAttributes: { 'attributeToRefresh' : 'newValue' } });
page.registerAttributeForRefresh('attributeToRefresh');