[Go to site: main page, start]

0% found this document useful (0 votes)
9 views131 pages

Alfresco JavaScript API

The document provides an overview of the JavaScript API for Alfresco, which allows developers to create and manipulate repository objects using JavaScript. It details the functionalities available through the API, including finding nodes, modifying properties, and creating new objects, as well as the structure and access methods for script files. Additionally, it outlines the various root objects and services accessible within the API, facilitating interaction with the Alfresco repository.

Uploaded by

kkosikov01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views131 pages

Alfresco JavaScript API

The document provides an overview of the JavaScript API for Alfresco, which allows developers to create and manipulate repository objects using JavaScript. It details the functionalities available through the API, including finding nodes, modifying properties, and creating new objects, as well as the structure and access methods for script files. Additionally, it outlines the various root objects and services accessible within the API, facilitating interaction with the Alfresco repository.

Uploaded by

kkosikov01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Published on Alfresco Documentation ([Link]

com)
Home > Alfresco Community Edition 5.1 > Developer guide > API guide > Reference > JavaScript API

JavaScript API
The Repository JavaScript API lets you develop JavaScript (ECMAScript) 1.6 compatible files to access, modify, and create Alfresco repository
objects such as nodes, aspects, and properties.

Use the JavaScript API for web scripts that execute JavaScript in the repository.

You can use scripts to perform the following functions:

Find nodes
Perform searches
Walk node hierarchies
Modify the value of properties, aspects, and associations
Transform and manipulate content
Create groups, people, and modify permissions
Create new files, folders, or nodes
Copy, move, and delete nodes
Create, modify, and remove child and target associations between nodes
Include or import other scripts

About script files [1] Script files are generally located either on the classpath (for example,
./tomcat/shared/classes/alfresco/extension/templates/webscripts), or in a repository store (for example, the default repository in Company
Home/Data Dictionary/Scripts)
Root objects [2] The JavaScript API provides a number of root objects which are available from your JavaScript code.
Scripting API [3] The Alfresco JavaScript API provides a rich set of scriptable Java objects.
Services API [4] The Alfresco JavaScript Services API provides an interface to core Alfresco services that can be accessed from web
scripts.

Parent topic: Reference [5]

About script files


Script files are generally located either on the classpath (for example, ./tomcat/shared/classes/alfresco/extension/templates/webscripts), or in a
repository store (for example, the default repository in Company Home/Data Dictionary/Scripts)

You can directly access scripts in the repository location using a URL with the appropriate read permissions on the script document. You can
import scripts on the classpath into other scripts but you cannot execute them directly in the Alfresco web client.

Importing scripts
This feature allows you to build libraries of scripts for use by other scripts at runtime. The syntax to import the scripts is specific to Alfresco and
is not a feature of standard JavaScript. For example, the <script src='...'> syntax, as supported by most web browsers, is not part of standard
ECMA JavaScript and will not work in Alfresco.

The syntax to import other scripts is very strict and you must follow it exactly; otherwise, the import can fail. Import directives must be the first
lines in the JavaScript file. This means that no code or comments are allowed above those lines, and the usual JavaScript code and comments
appear after the import lines. Only the following syntax variants are supported:

Import a script from the repository using a name­based path:

<import resource="/Company Home/Data Dictionary/Scripts/[Link]">

Import a script from the repository using a NodeRef reference:

<import resource="workspace://SpacesStore/6f73de1b‐d3b4‐11db‐80cb‐112e6c2ea048">

Import a script from a Java classpath location:

<import resource="classpath:alfresco/extension/[Link]">

Parent topic: JavaScript API [6]

Root objects
The JavaScript API provides a number of root objects which are available from your JavaScript code.
The root objects have various types, depending on which part of the system they expose. For example, the common Alfresco repository
concepts, such as the Company Home folder and the logged in user, are represented through objects of type ScriptNode. These objects support
the full range of properties and object­oriented API of the ScriptNode class.

Depending on the context in which the script is invoked, other types of root object are available that represent aspects of the system such as
server details, user information, request headers and parameters passed to the script. Further, a variety of Alfresco services are accessible
from your JavaScript code, each of these services has a corresponding root object, on which properties can be accessed and a variety of
methods called as dictated by the service's API.

See also Web script reference guide, which covers root objects in more detail. [7]

The root objects available to your JavaScript code will depend on the context in which the code is invoked. Different contexts will have access
to a different set of root objects. There are several contexts to be considered:

Web scripts
Surf
Rules/actions
Workflow
Share

This information looks at the most commonly used root objects. More specialized root objects are described in more detail in the relevant
sections of this documentation.

Further information on root objects provided by services and the exposed APIs can be found in the Services API reference [8].

See also the related links.

Simple root objects


The following table lists root objects that do not expose an API, but consist of simple data structures or types:

Root Object Type in Script Runtime Description


guest Boolean True if the user is logged in as a guest
server Object Server details
model Object Used to pass a model from the control script to the view renderer (template). Web scripts only.

Root objects that expose ScriptNode objects


The following table lists root objects that expose ScriptNode objects:

Root
Object Type in Script Runtime Description
companyhome [Link] The company home ScriptNode. See ScriptNode API for properties and methods.
document [Link] The current node ScriptNode (if any)
person [Link] The ScriptNode representing the Person object of the currently authenticated user. See
ScriptNode API for properties and methods.
roothome [Link] The store root ScriptNode. The repository root folder. See ScriptNode API for properties
and methods.
script [Link] The ScriptNode representing the script object itself. This is only available if the script is
loaded from the Java classpath.
space [Link] The primary parent ScriptNode for the current node (ScriptNode). For a script executing
from a rule, the space object is the space in which the rule resides. If the rule is inherited,
this might not be the expected space.
userhome [Link] The current user's Home Space ScriptNode. See ScriptNode API for properties and
methods.

Root objects also available in web scripts


The following table lists root objects that are available when the script is running as a web script. See the web script reference for additional
information on these root objects.

Root Object Type in Script Runtime Description


args List List of arguments passed to the script
argsM List List of arguments passed to the script
cache Object Object containing cache information
headers List List of headers passed to the script
headersM List List of headers passed to the script
session Object Object containing session information for the user connection
url Object Object containing information about the URL used to invoke web script

Root objects that expose additional APIs


The following table lists root objects that expose additional APIs:

Root Object Type in Script Runtime Description


actions [Link] Root object providing invocation of registered Alfresco actions
activities [Link] Root object providing access to the Activity API.
appUtils [Link] Root object providing access to methods specifically for
external application use
bulkFSImport [Link] Bulk Import object
classification [Link] Access to the root elements of the Classification API
cmis [Link] CMIS client
cmisServer [Link] CMIS server REST access
crossRepoCopy [Link] Cross repository copy support.
imap [Link] Root object providing access to Imap methods for mailbox
support
format [Link] Format model
jsonUtils [Link] JSON utilities. Web scripts only.
logger [Link] Root object providing access to console logging facilities for
script debugging
msg [Link] Web scripts only
paging [Link] Paging API. web scripts only.
people [Link] Root object providing access to and manipulation of person
objects and groups
presence [Link] Root object providing access to methods for detecting online
presence of users
search [Link] Root object providing access to the various Alfresco search
interfaces such as FTS­Alfresco, Lucene, XPath, and Saved
Search results

session [Link] Session­related information such as the current


authentication ticket
slingshotDocLib [Link] Slingshot
stringUtils [Link] String utilities
test [Link] Root object providing access to test utilities
utils [Link] Root object providing access to a library of helper functions
that are not provided as part of generic JavaScript
webprojects [Link] Root object providing access to the WCM JavaScript API.
This facilitates access to web projects, sandboxes, WCM
assets, and project membership.
workflow [Link] Root object providing access to the workflow service.

Root Objects that expose services


The following table lists root objects that expose services:

Root Object Type in Script Runtime Description


actionTrackingService [Link] Root of the Action Tracking Service
atom [Link] Atom service
commentService [Link] Root of the Comment Service
formService [Link] Root of the Form Service
groups [Link] Root of the Group authorities providing access to
advanced authority APIs for manipulating groups
and zones.
invitations [Link] Root of the Invitations API providing access to
invitations for web sites.
preferenceService [Link] Root of the Preference Service
ratingService [Link] Root of the Rating Service
renditionService [Link] Root of the Rendition Service
replicationService [Link] Root of the Replication Service
siteService [Link] The root of sites service providing access to the
sites service.
taggingService [Link] Root of the Tagging Service
thumbnailService [Link] Root of the Thumbnail Service
transfer [Link] The root of transfer service providing access to
the transfer service.
Parent topic: JavaScript API [6]
Related concepts
Web script reference guide [7]
Related reference
Surf root objects guide [9]

Scripting API
The Alfresco JavaScript API provides a rich set of scriptable Java objects.

Many root­scope objects are provided by default, such as access to the user home folder, company home folder, WCM web projects, search,
People API, and logging functionality. You can also configure additional root­scope objects for use with your own scripts.

ScriptNode API [10] In JavaScript code various parts of the underlying system can be conveniently exposed as objects of type ScriptNode.
For example, the companyhome, userhome, document, space, and person objects are best represented as objects of type ScriptNode. The
ScriptNode API provides access to properties and methods for manipulating this type of object.
Actions API [11] The actions API provides a root level actions object that allows invocation of Alfresco actions registered with the
repository.
Classification API [12] The Classification API has two parts: manipulating classifications, and manipulating the categories they contain.
Logging API [13] A root level logger object provides a number of methods to help debug scripts.
People API [14] The People API provides access to Alfresco people and groups.
ScriptAction API [15] A ScriptAction represents an Alfresco action registered within the repository.
Search API [16] The Search API provides direct access to repository level search results and Saved Search results through the search root
scope object.
Session API [17] A root level session object is provided to access the servelt web session.
SessionTicket API [18] A root level sessionticket object is provided to access the current logged in user session ticket as a string value.
Utility methods [19] A root level utils object is provided as a library of helper methods that are missing from generic JavaScript.

Parent topic: JavaScript API [6]

ScriptNode API
In JavaScript code various parts of the underlying system can be conveniently exposed as objects of type ScriptNode. For example, the
companyhome, userhome, document, space, and person objects are best represented as objects of type ScriptNode. The ScriptNode API provides
access to properties and methods for manipulating this type of object.

Additional APIs and properties


In addition to the properties shown in the table [20], the ScriptNode object API also exposes a number of additional properties and APIs which
have been grouped by functional purpose in this documentation. These additional APIs include:

Security API [21]


Ownership API [22]
Modifying and creating API [23]
Checkin/Checkout API [24]
Versions API [25]
Content API [26]
ScriptContentData API [27]
Transformation API [28]
Thumbnail API [29]
Tagging API [30]

Properties
The following properties are available to use within scripts:

Property Read/write Description


activeWorkflows Read­only
Returns an array of all active workflows in which this node is involved. Null is returned if the node is not part
of an active workflow.

The following code snippet obtains a list of workflow objects for the file TEST_FILE_0.TXT:

var node = [Link]("TEST_FILE_0.TXT");


var workflows = [Link];

aspects Read­only A read­only array of the fully qualified QName strings applied to the node
aspectsSet Read­only A list of aspects applied to this node
aspectsShort Read­only An array of aspects as short prefix qnames applied to this node
associations Read­only The same as assocs
assocs Read­only A read­only associative array of the target associations of the node. Each named entry in the array contains
an array of the script node objects on the end of the association.

Example: [Link]["cm:translations"][0]

childAssociations Read­only Same as childAssocs


childAssocs Read­only A read­only associative array of the child associations of the node. Each named entry in the array contains
an array of the script node objects on the end of the association.

Example: [Link]["fm:discussion"][0]

children Read­only A read­only JavaScript array of the child node objects

Example: [Link][0]

content Read­write The content string for this node from the default content property (ContentModel.PROP_CONTENT).
displayPath Read­only A read­only display path to this node
downloadUrl Read­only For a content document this is a read­only string representing the download (as attachment) URL for the
content. For a container node this would be an empty string.
hasChildren Read­only True if the node has children
icon16 Read­only A read­only small icon image for this node
icon32 Read­only A read­only large icon image for this node
id Read­only The GUID for the node
isCategory Read­only Returns true if this node is a category, or false otherwise
isContainer Read­only Returns true if the node is a folder node, or false otherwise
isDocument Read­only Returns true if this node is a document, or false otherwise
isLinkToContainer Read­only Returns true if this node is a link to a container, or false otherwise
isLinkToDocument Read­only Returns true if this node is a link to a document, or false otherwise
isLocked Read­only Returns true if the node is locked, or false otherwise. Once a node is checked out it becomes locked.
mimetype Read­write A read/write value representing the MIME type of the content

name Read­write Shortcut access to the cm:name property. Can be read and written to.
nodeRef Read­only The NodeRef corresponding to this node
parent Read­only Primary parent node. This will be null if this is the root node.
parentAssociations Read­only Same as parentAssocs
parentAssocs Read­only A read­only associative array of the parent associations of the node. Each named entry in the array contains
an array of the script node objects on the end of the association.
Example: [Link]["cm:contains"][0]

parents Read­only Array of the parent nodes


primaryParentAssoc Read­only The primary parent association so it is possible to obtain the association QName and the association type
QName
properties Read­only Provides access to all the properties of this node. The properties returned are accessed by using an
associative array. Properties of a node can be accessed in the following ways:

Example: [Link]["name"]

Example: [Link]

qnamePath Read­only A read­only QName type path to this node


qNameType Read­only The QName type
siteShortName Read­only Returns the name of the site this node is contained within. If the node is not contained within a site, the
value is null
size Read­only A read­only long value that represents the size (in bytes) of the content attached to the node from the
default content property.
sourceAssociations Read­only The same as sourceAssocs
sourceAssocs Read­only A read­only associative array of the source associations of the node. Each named entry in the array
contains an array of the script node objects on the end of the association.

Example: [Link]["cm:translations"][0]

storeId Read­only The store id for the node


storeType Read­only The store type for the node
type Read­only Fully qualified QName type of the node
typeShort Read­only Returns the type of the node as a short form qname.
url Read­only For a content document, this method returns the URL to the content stream for the default content property.
For a container node, this method returns the URL to browse to the folder in the web­client.
webdavUrl Read­only A read­only string representing the webdav URL for the content

getPropertyNames [31]getPropertyNames(useShortQNames) returns all the property names defined for this node as an array.
getTypePropertyNames [32]getTypePropertyNames returns all the property names defined for this node's type as an array.
childByNamePath [33]childByNamePath(path) performs a path­based query based on the name property of the nodes.
childrenByXPath [34]childrenByXPath(xpath) performs an XPath­based query relative to the current node.
childFileFolders [35] The childFileFolders methods are used to obtain an array of child files and folders for the node.
isScriptContent [36]isScriptContent(obj) determines whether the supplied node property value is a ScriptContentData object.
hasAspect [37]hasAspect(type) returns true if an aspect was applied to the node.
getChildAssocsByType [38]getChildAssocsByType(String type) returns an array of the associations from the referenced node that match a
specific object type.
isSubType [39]isSubType(type) determines if this node is a subtype of the specified type.
exists [40]exists() checks whether the node exists in the repository.
reset [41]reset() resets the node cached state of a node.
toJSON [42]toJSON() returns the JSON representation of this node.
Security/Permissions API [43] The Security ScriptNode API features several methods and properties related to permissions of nodes in
the repository.
Ownership API [44] The Ownership ScriptNode API provides methods to get, set and take ownership of a node.
Modifying and creating API [45] Most of the available ScriptNode API return read­only values, however the Scripting API also supports
writable objects and access to Alfresco repository services.
Check in/check out API [46] The check in/check out ScriptNode API features methods for check out, check in, and cancelling check out of
working copies.
Versions API [47] The Versions ScriptNode API provides several methods and properties for managing and retrieving the versions of a
document.
Content API [48] The Content API provides several properties to manipulate node content directly. The content can also be manipulated
using the ScriptContentData API.
ScriptContentData API [49] The ScriptContentData API provides several methods and properties related to node properties of type
d:content; for example, [Link].
Transformation API [50] The Transformation API provides document, image, and FreeMarker template processing services in Alfresco.
Thumbnail API [51] A thumbnail is a transformation of content into a specified destination MIME type. This is most commonly an image of
a particular size, but can also be other things, for example, a Flash rendition. The ScriptNode class provides several methods for
generating and handling thumbnails.
Tagging API [52] A tag is a non­hierarchical keyword or term assigned to a piece of information.

Parent topic: Scripting API [3]


getPropertyNames
getPropertyNames(useShortQNames) returns all the property names defined for this node as an array.

Parameters
useShortQNames
If true short­form qnames will be returned, else long­form.

Returns
Returns an array of property names for this node type and optionally parent properties.

Example
var props = [Link](true);

Parent topic: ScriptNode API [10]

getTypePropertyNames
getTypePropertyNames returns all the property names defined for this node's type as an array.

Parent topic: ScriptNode API [10]

getTypePropertyNames

getTypePropertyNames(useShortQNames) ­ Returns all the property names defined for this node's type as an array.

Returns

Returns an array of property names for this node's type. Short qnames are returned.

Example
var props = [Link]();

getTypePropertyNames (boolean)

getTypePropertyNames(useShortQNames) ­ Return all the property names defined for this node's type as an array.

Parameters

useShortQNames
If true short­form qnames will be returned, else long­form.

Returns

Returns an array of property names for this node's type.

Example
var props = [Link](false); // return long form qnames

childByNamePath
childByNamePath(path) performs a path­based query based on the name property of the nodes.

Parameters
path
The path to the node.

Returns
Returns a node found at the specified path relative to the current node. If this is not found, null is returned.

Example
var testingFolder =[Link]("QA/Performance/Testing");

Parent topic: ScriptNode API [10]

childrenByXPath
childrenByXPath(xpath) performs an XPath­based query relative to the current node.

Parameters
xpath
XPath query to select nodes.

Returns
Returns an array of the nodes found. If no results are matched, returns an empty array.

Example
var nodes = [Link]("*[@cm:name='Finance Documents']/*");

Parent topic: ScriptNode API [10]

childFileFolders
The childFileFolders methods are used to obtain an array of child files and folders for the node.
Parent topic: ScriptNode API [10]

childFileFolders()

Returns an array of child files and folders for the node.

Returns
Returns a JavaScript array of child file and folder nodes for the node. It automatically retrieves all sub­types of cm:content and cm:folder, and
removes system type folders from the results.

Example

var nodes = [Link]();

childFileFolders(files, folders)

Returns an array of child files and folders for the node, and as modified by parameters.

Parameters

files
A boolean value which if set to true specifies that files extending from cm:content should be returned.
folders
A boolean value which if set to true specifies that folders extending from cm:folder should be returned, ignoring sub­types of
cm:systemfolder.

Returns
Returns a JavaScript array of child file and folder nodes for the node. It automatically retrieves all sub­types of cm:content and cm:folder, and
removes system type folders from the results.

Example

var nodes = [Link](false, true); // don't return files

childFileFolders(files, folders, ignoreTypes)


Returns an array of child files and folders for the node, and as modified by parameters.

Parameters
files
A boolean value which if set to true specifies that files extending from cm:content should be returned.
folders
A boolean value which if set to true specifies that folders extending from cm:folder should be returned, ignoring sub­types of
cm:systemfolder.
ignoreTypes
Can be set to filter nodes of the specified type or types from the results returned. The type is specified in either long or short QName
string form, as a single string or as an array of strings to filter multiple types.

Returns

Returns a JavaScript array of child file and folder nodes for the node. It automatically retrieves all sub­types of cm:content and cm:folder, and
removes system type folders from the results.

Example
var nodes = [Link](true, true, "cm:folder"); // ignore folders
var nodes = [Link](true, true, ["cm:folder", "st:sites"]); // ignores folders and sites

childFileFolders(files, folders, ignoreTypes, maxItems)

Returns a ScriptPagingNode object containing child files and folders for the node, as well as information to control paging of results. Parameters
can be used to filter results. It is also possible to limit the number of nodes returned in the results.
CAUTION:
This method is deprecated in version 4.0.

Parameters

files
A boolean value which if set to true specifies that files extending from cm:content should be returned.
folders
A boolean value which if set to true specifies that folders extending from cm:folder should be returned, ignoring sub­types of
cm:systemfolder.
ignoreTypes
Can be set to filter nodes of the specified type or types from the results returned. The type is specified in either long or short QName
string form, as a single string or as an array of strings to filter multiple types.
maxItems
An integer value which sets the maximum number of results to return.

Returns

Returns a ScriptPagingNode object. The results are limited to the number specified by maxItems.

Example
var nodeNames = new Array();
var nodes = null;
var maxItems = 10;

var results = [Link](true, false, "st:sites", maxItems);

nodes = [Link]();

for (var n in nodes){


[Link](nodes[n]['name']);
}

childFileFolders(files, folders, ignoreTypes, skipOffset, maxItems, requestTotalCountMax,


sortProp, sortAsc, queryExecutionId)

Returns child files and folders of the node.

Parameters

files
A boolean value which if set to true specifies that files extending from cm:content should be returned.
folders
A boolean value which if set to true specifies that folders extending from cm:folder should be returned, ignoring sub­types of
cm:systemfolder.
ignoreTypes
Can be set to filter nodes of the specified type or types from the results returned. The type is specified in either long or short QName
string form, as a single string or as an array of strings to filter multiple types.
skipOffset
Number of items to skip. For example 0, or number of pages to skip * size of page.
maxItems
An integer value which sets the maximum number of items, the size of the page.
requestTotalCountMax
Request total count (up to a given max total count) Note, if set to 0 then total count is not requested and the query might be able to
optimise/cutoff for max items.
sortProp
Optional sort property as a prefix QName string, for example cm:name. Also supports special content cases such as cm:[Link] and
cm:[Link].
sortAsc
A boolean value. If true nodes will be sorted in ascending order, if false nodes will be sorted in descending order.
queryExecutionId
If paging then can pass back the previous query execution (as a hint for possible query optimization). Note this parameter is not used, it is
reserved for future use.

Returns
Returns a ScriptPagingNode containing child file and folder nodes for the node. It automatically retrieves all sub­types of cm:content and
cm:folder, and removes system type folders from the results.

Example
var queryExecutionId = null; // reserved for future use

var results;
var nodeNames = new Array(); // just store file names in a list
var resultsTrimmed = false;
var nodes = null;

// get files ordered by name (exclude folders and st:sites)


results = [Link](true, false, "st:sites", 0, 100, 0, "cm:name", true, queryExecutionId);

nodes = [Link]();

for (var n in nodes){


[Link](nodes[n]['name']);
}

resultsTrimmed = [Link](); // did we get all possible child files/folders?

isScriptContent
isScriptContent(obj) determines whether the supplied node property value is a ScriptContentData object.

Parameters
obj
Node property value

Returns
Boolean. Returns true if the supplied node property value is a ScriptContentData object; otherwise, it returns false.

Parent topic: ScriptNode API [10]

hasAspect
hasAspect(type) returns true if an aspect was applied to the node.

Parameters
type
The type of aspect whose presence will be checked for. Examples include cm:versionable and cm:templatable.

Returns
Boolean
Example
var isTemplatable = [Link]("cm:templatable");
...
var node = [Link]("TEST_FILE_0.TXT");
[Link] = [Link]("cm:versionable");

Parent topic: ScriptNode API [10]

getChildAssocsByType
getChildAssocsByType(String type) returns an array of the associations from the referenced node that match a specific object type.

Parameters
type
A string representing the specific object type.

Returns
Returns the aspects applied to this node as an array of short prefix qname strings.

Example
var assoc = [Link]("cm:folder")[0];

Parent topic: ScriptNode API [10]

isSubType
isSubType(type) determines if this node is a subtype of the specified type.

Parameters
type
The qname type to test this object against (fully qualified or short­name form).

Returns
Returns true if this node is a subtype of the specified type (or itself of that type).

Parent topic: ScriptNode API [10]

exists
exists() checks whether the node exists in the repository.

Returns
Returns a boolean, true if the node exists, false otherwise.

Example
if ([Link]()){
...
}

Parent topic: ScriptNode API [10]

reset
reset() resets the node cached state of a node.

This resets properties as follows:


[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = null;
[Link] = false;

Example
The following would reset the cached state of the node:
[Link]();

Parent topic: ScriptNode API [10]

toJSON
toJSON()returns the JSON representation of this node.
Parent topic: ScriptNode API [10]

toJSON

toJSON() ­ returns the JSON representation of this node. Long­form QNames are used in the result.

Returns

Returns the JSON representation of this node.

toJSON

toJSON(boolean useShortQNames) ­ returns the JSON representation of this node. Short­form QNames are used in the result.

Parameters

boolean useShortQNames
If true, short­form QNames will be returned, else long­form QNames will be returned.

Returns

Returns the JSON representation of this node.

Security/Permissions API
The Security ScriptNode API features several methods and properties related to permissions of nodes in the repository.

The Security API provides a wide range of methods for setting and getting permissions on nodes. It is good practice to check for the
appropriate user permissions on a node before accessing or modifying it.

Properties
permissions
Array of permissions applied to this node, including inherited permissions.

directPermissions
Array of permissions applied to this node, excluding inherited permissions.

fullPermissions
Array of all permissions applied to this node, including inherited permissions.

settablePermissions
Array of settable permissions for this node.
hasPermission [53]hasPermission(permission) checks if a user has the specified permission on a node.
inheritsPermissions [54]inheritsPermissions() indicates whether the node inherits permissions.
setInheritsPermissions [55]setInheritsPermissions(inherit) indicates that the node should inherit permissions from the parent node when
set to true. Set to false to break the inheritance chain.
setPermission [56] The setPermission methods apply permissions to nodes.
removePermission [57] The removePermission methods remove permissions for users from a node.
getPermissions [58]getPermissions() returns an array of permissions attached to a node.

Parent topic: ScriptNode API [10]

hasPermission
hasPermission(permission) checks if a user has the specified permission on a node.

The default permissions are in [Link]. The most commonly used permission checks are:

Read
Write
Delete
AddChildren
CreateChildren

Parameters
permission
The specified permission

Returns
Returns true if the user has the specified permission on the node.

Parent topic: Security/Permissions API [43]

inheritsPermissions
inheritsPermissions() indicates whether the node inherits permissions.

Returns
Returns true if the node currently inherits its permissions from the parent space, and returns false to indicate the permissions are set
specifically on the node.

Parent topic: Security/Permissions API [43]

setInheritsPermissions
setInheritsPermissions(inherit) indicates that the node should inherit permissions from the parent node when set to true. Set to false to break
the inheritance chain.

Parameters
inherit
True to indicate the node inherits from its parent. False, indicates the node should not inherit permissions from the parent node.

Parent topic: Security/Permissions API [43]

setPermission
The setPermission methods apply permissions to nodes.
Parent topic: Security/Permissions API [43]

setPermission(permission)

setPermission(permission)

This method applies a permission to the node.


Parameters

permission
The permission to apply to the node.

setPermission(permission, authority)

setPermission(permission, authority)

This method applies a permission for the specified authority (for example, a user name or group) to the node.

Note that the method does not check for the presence of the specified authority, so the method will not fail if a non­existent user is specified.
The existence of a user or group should be checked for in preceding code for additional robustness.

Parameters

permission
The permission to apply to the node.
authority
The authority (user, group) for which the permission will be applied.

Example
var node = [Link]("TEST_FILE_0.TXT");

[Link]("Read", "[Link]");
[Link]("Delete", "Admin");
[Link]("Write", "GROUP_EVERYONE");
[Link]("Delete", "GROUP_ALFRESCO_ADMINISTRATORS");
[Link]("Delete", "[Link]"); // user doesn't exist!

[Link] = [Link]();

This would result in the following permissions being set:


ALLOWED;[Link];Read

ALLOWED;[Link];Delete

ALLOWED;Admin;Delete

ALLOWED;GROUP_EVERYONE;Write

ALLOWED;GROUP_ALFRESCO_ADMINISTRATORS;Delete

removePermission
The removePermission methods remove permissions for users from a node.
Parent topic: Security/Permissions API [43]

removePermission(permission)

removePermission(permission) removes a permission for all users from the node.

Parameters

permission
The permission to remove.

removePermission(permission, authority)

removePermission(permission, authority) removes a permission for the specified authority (for example, a user name or group) from the node.

Parameters

permission
The permission to remove.
authority
The authority, typically a user name or group, to remove the permission for.

Example
var node = [Link]("TEST_FILE_0.TXT");
[Link]("Read", "[Link]");
[Link]("Delete", "Admin");
[Link]("Write", "GROUP_EVERYONE");
[Link]("Delete", "GROUP_ALFRESCO_ADMINISTRATORS");

//...

[Link]("Read", "[Link]");

[Link] = [Link]();

The resulting permissions would be:

ALLOWED;Admin;Delete

ALLOWED;GROUP_EVERYONE;Write

ALLOWED;GROUP_ALFRESCO_ADMINISTRATORS;Delete

getPermissions
getPermissions() returns an array of permissions attached to a node.

Returns
An array of permissions applied to this node, including inherited permissions.

Strings returned are of the format [ALLOWED|DENIED];[USERNAME|GROUPNAME];PERMISSION. An example is ALLOWED;GROUP_EVERYONE;Consumer. The string
can then be tokenized on the ';' character.

Example
var node = [Link]("TEST_FILE_0.TXT");
[Link] = [Link]();

Parent topic: Security/Permissions API [43]

Ownership API
The Ownership ScriptNode API provides methods to get, set and take ownership of a node.

Properties
owner
The owner property of the node (as a UID)

takeOwnership [59]takeOwnership() this method results in the authenticated user running the script to take ownership of the node.

Parent topic: ScriptNode API [10]

takeOwnership
takeOwnership() this method results in the authenticated user running the script to take ownership of the node.

Example
If running the script while authenticated as admin, the following code would result in admin being returned as the owner.

var node = [Link]("TEST_FILE_0.TXT");

[Link]("[Link]"); // owner is now '[Link]'

//...

[Link](); // currently authenticated user running script is 'admin'

[Link] = [Link]();

Parent topic: Ownership API [44]

Modifying and creating API


Most of the available ScriptNode API return read­only values, however the Scripting API also supports writable objects and access to Alfresco
repository services.

The ScriptNode object lets you modify and add properties, add aspects, create new files, folder, and custom type nodes, and update and set the
text content stream for a node. You can also delete nodes, transform content, execute templates, and modify the associations for a node.

Remember: JavaScript objects are different to native repository Java objects. Property values in the repository must be the correct object type
as defined in the Data Dictionary and exposed by the content model. This means that a string property value expects a Java string, and a multi­
valued property expects a list. The Alfresco JavaScript API converts most object types between JavaScript and Java for you such as Array (for
a multi­value property), numbers, dates, Boolean, and strings. The conversion code handles all common type conversions and recursive lists of
those types.
Type Description
properties Property array (can be modified for updating or adding new properties)

Example:

// change the name of this document [Link] = "Backup of " + [Link];


// add a new property string [Link]["cm:locale"] = mylocalenode; // save the property
modifications [Link]();

The [Link]() API call is required to persist the property modifications. All other modifications made
using the API, such as content or adding aspects, take immediate effect.

content A property to modify the text content of a node

Example: [Link] = [Link] + "append some text";

name A helper property (a shortcut for [Link]) to get/set the name

createFolder [60] The createFolder methods create a new folder as a child of the current node.
createFile [61] The createFile methods create a new file as a child of the current node. Once created the file should have content set
using the content property.
createNode [62] The createNode methods are used to create new nodes.
addNode [63] The addNode(node) method adds an existing node as a child of this node.
removeNode [64]removeNode(node) removes all parent­child relationships between two nodes.
createAssociation [65]createAssociation(target, assocType) creates a new target association to the specified node with the given
association type QName.
removeAssociation [66]removeAssociation(target, assocType) removes the association to the specified node with the given association
type QName.
remove [67]remove() this method deletes the node.
copy [68] The copy
move [69]move moves the node to the specified destination.
addAspect [70] The addAspect methods are used to add new aspects to nodes.
removeAspect [71]removeAspect(aspect) removes the specified aspect from the node.
specializeType [72]specializeType(type) specializes the type of a node.
revert [73]revert reverts node to the specified version.
save [74]save() persists the modified properties of this node.

Parent topic: ScriptNode API [10]

createFolder
The createFolder methods create a new folder as a child of the current node.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parent topic: Modifying and creating API [45]

createFolder(name)
createFolder(name) this method creates a new folder (cm:folder) node with the specified name as a child of this node.

Parameters

name
The folder name

Returns

Returns the new node as the result of the function or returns null if the creation fails.

Example
var myfolder = [Link]("New Folder");

createFolder(name, type)
createFolder(name, type) this method creates a new folder (cm:folder) node with the specified name and type as a child of this node.

Parameters
name
The folder name
type
The type of the folder to create. If null it defaults to type ContentModel.TYPE_FOLDER. Examples of folder types include cm:systemfolder,
cm:folder, st:site, and fm:forum.

Returns

Returns the new node as the result of the function or returns null if the creation fails.

Example

var myfolder = [Link]("New Folder", "st:site");

createFile
The createFile methods create a new file as a child of the current node. Once created the file should have content set using the content
property.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] on the node first.

Parent topic: Modifying and creating API [45]

createFile(name)

createFile(name) this method creates a new file node of type cm:content with the specified name. The node is created as a child of the current
node.

Parameters
name
The name of the file to create

Returns

Returns the newly created node as the result of the function, or returns null if the creation failed. Alfresco puts the file MIME type of the content
(there is no MIME type with the createNode method).

Example

var myfile = [Link]("[Link]");

createFile(name, type)

createFile(name) this method creates a new file node of type cm:content with the specified name. The node is created as a child of the current
node.

Parameters
name
The name of the file to create
type
The type of file to create. If null will create ContentModel.TYPE_CONTENT.

Returns

Returns the newly created node as the result of the function, or returns null if the creation failed. Alfresco puts the file MIME type of the content
(there is no MIME type with the createNode method).

Example
var myfile = [Link]("[Link]", "cm:content");
createNode
The createNode methods are used to create new nodes.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parent topic: Modifying and creating API [45]

createNode(name,type)

This method creates a new node of the specified type (a QName in either full or short form).

Parameters

name
The node name. Name of the node to create (can be null for a node without a 'cm:name' property).
type
The node type. QName type (fully qualified or short form such as 'cm:content').

Returns

Newly created node, or null if failed to create.

Example

var node = [Link]("My Discussion", "fm:forum");

createNode(name, type, assocType)

This method creates a new node of the specified type as a child of the current node with the given child association type.

Parameters

name
The node name. Name of the node to create (can be null for a node without a 'cm:name' property).
type
The node type. QName type (fully qualified or short form such as 'cm:content').
assocType
The QName of the child association type (fully qualified or short form, for example, 'cm:contains')

Example
var node = [Link]("My Discussion", "fm:forum", "fm:discussion");

createNode(name, type, properties)

This method creates a new node as a child of the current node with the specified properties.

Parameters

name
The node name. Name of the node to create (can be null for a node without a 'cm:name' property).
type
The node type. QName type (fully qualified or short form such as 'cm:content').
properties
An associative array of the properties to be added to the node upon creation. This is useful when a type requires the setting of mandatory
properties.

Returns

Newly created node, or null if failed to create.

Example
var node = [Link]("Sites/test");
var forumName = "My Forum";
var properties = new Array();
properties['cm:title'] = "The forum title";
properties['cm:description'] = "The forum description";
var forum = [Link](forumName, "fm:forum", properties);
createNode(name, type, properties, assocType)

This method creates a new node as a child of the current node. The node contains the specified child association name with the specified
properties with that child association type.

Parameters
name
The node name. Name of the node to create (can be null for a node without a 'cm:name' property).
type
The node type. QName type (fully qualified or short form such as 'cm:content').
properties
An associative array of the properties to be added to the node upon creation.
assocType
The QName QName of the child association type (fully qualified or short form, for example, 'cm:contains').

createNode(name, type, properties, assocType, assocName)

This method creates a new node as a child of the current node. The node contains the specified child association name with the specified
properties, and the given child association type and name.

Parameters

name
The node name. Name of the node to create (can be null for a node without a 'cm:name' property).
type
The node type. QName type (fully qualified or short form such as 'cm:content').
properties
An associative array of the properties to be added to the node upon creation
assocType
The QName of the child association type (fully qualified or short form, for example, 'cm:contains').
assocName
The QName of the child association name (fully qualified or short form, for example, 'fm:discussion').

addNode
The addNode(node) method adds an existing node as a child of this node.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parameters
node
The node to add as a child of the current node.

Returns
void

Example
var dir = [Link]("SUB_FOLDER", "cm:folder");

var properties = new Array();


properties['cm:title'] = "Node title";
properties['cm:description'] = "Node description";

var node = [Link]("SUPER_FILE.TXT", "cm:content", properties);


[Link] = "Node content";

// now add as child of sub folder

[Link](node);
[Link] = node;

Parent topic: Modifying and creating API [45]


removeNode
removeNode(node) removes all parent­child relationships between two nodes.

The child node will be cascade deleted if one of the associations was the primary association, that is, the one with which the child node was
created.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parameters
node
The node to be removed.

Example
var dir = [Link]("SUB_FOLDER");
var node = [Link]("SUPER_FILE.TXT");

// delete child from parent

[Link](node);

Parent topic: Modifying and creating API [45]

createAssociation
createAssociation(target, assocType) creates a new target association to the specified node with the given association type QName.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parameters
target
Destination node for the association
assocType
Association type qname (short form or fully qualified)

Returns
The new association.

Parent topic: Modifying and creating API [45]

removeAssociation
removeAssociation(target, assocType) removes the association to the specified node with the given association type QName.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parameters
target
Destination node on the end of the association
assocType
Association type qname (short form or fully qualified)

Parent topic: Modifying and creating API [45]

remove
remove() this method deletes the node.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Returns
Returns true on success, or false otherwise.

Example
Any variable or references to the ScriptNode should be discarded. For example:
[Link]();
Parent topic: Modifying and creating API [45]

copy
The copy
methods are used to copy nodes to specified destination nodes.

Parent topic: Modifying and creating API [45]

copy(destination)

This method copies the node to the specified destination node.

Parameters

destination
The destination node

Returns
Returns the newly copied ScriptNode instance on success, or null if the copy fails.

Example

var docCopy = [Link](userhome);

copy(destination, deepCopy)

This method copies the node to the specified destination node. It copies all child nodes of the source if the deepCopy argument is true.
Otherwise, it only copies the source node itself.

Parameters

destination
The destination node
deepCopy
True for a deep copy, false otherwise.

Returns

Returns the newly copied ScriptNode instance on success, or null if the copy fails reason.

Example

var docCopy = [Link](userhome, true);

move
movemoves the node to the specified destination.
Parent topic: Modifying and creating API [45]

move(destination)

move(destination) this method moves the node to the new parent destination.

Parameters

destination
The destination node.

Returns
Boolean

Returns true on success, or false on failure to move

move(source, destination)

move(source, destination) this method moves the specified source node to the new parent destination.

Parameters
source
The source node.
destination
The destination node.

Returns

Boolean

Returns true on success, or false on failure to move

addAspect
The addAspect methods are used to add new aspects to nodes.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parent topic: Modifying and creating API [45]

addAspect(aspect)

This method adds a new aspect and properties to the node allowing mandatory aspect properties to be supplied when the new aspect is
applied.

Parameters

aspect
The aspect to add

Returns
True if the aspect was added successfully, false otherwise.

Example

[Link]("cm:translatable");

addAspect(aspect, properties)

This method adds a new aspect and properties to the node allowing mandatory aspect properties to be supplied when the new aspect is
applied.

Parameters

aspect
The aspect to add
properties
An associative array of QName keyed properties. Any mandatory properties for the aspect must be provided.

Returns
True if the aspect was added successfully, false otherwise.

Example
var props = new Array();
props["cm:template"] = [Link];
[Link]("cm:templatable", props);

removeAspect
removeAspect(aspect) removes the specified aspect from the node.

Note: Any unsaved property changes will be lost when this method is called. To preserve property changes call save() [75] first.

Parameters
aspect
The aspect type to remove

Returns
True if aspect removed, false otherwise.

Parent topic: Modifying and creating API [45]

specializeType
specializeType(type) specializes the type of a node.

Resets the type of the node. Can be called in order specialise a node to a sub­type. This should be used with caution since calling it changes
the type of the node and thus implies a different set of aspects, properties and associations. It is the responsibility of the caller to ensure that
the node is in an approriate state after changing the type.

Parameters
type
The type name supplied must be a subtype of the current type as defined in the Data Dictionary

Returns
Boolean. Returns true on success, false otherwise.

Parent topic: Modifying and creating API [45]

revert
revertreverts node to the specified version.
Parent topic: Modifying and creating API [45]

revert(history, majorVersion, versionLabel)

revert(history, majorVersion, versionLabel) this method reverts the node to the specified version.

The node must have the cm:versionable aspect. The node will be checked out if required and will be checked in after the call. This method does
not attempt to perform a deep revert of associations.

Parameters
history
A revision history note.
majorVersion
If set to true the method will try to save the changes as a major version increment. If false will save as a minor version increment.
versionLabel
The version label to revert from.

Returns

ScriptNode

Returns the original node that was checked out if reverted, or null if the specified version does not exist.

revert(history, majorVersion, versionLabel, deep)

revert(history, majorVersion, versionLabel, deep) revert this node to the specified version and potentially all child nodes.

The node must have the aspect cm:versionable. The node will be checked out if required, and checked in on completion of the call.

Parameters
history
A revision history note.
majorVersion
If set to true the method will try to save the changes as a major version increment. If false will save as a minor version increment.
versionLabel
The version label to revert from.
deep
If set to true the method will perform a deep revert. If set to false a deep revert will not be performed, and only the current node will be
reverted.

Returns
ScriptNode

Returns the original node that was checked out if reverted, or null if the specified version does not exist.

save
save() persists the modified properties of this node.

Example
var node = [Link]("TEST_FILE_1.TXT");

[Link] = "This is an example description.";


[Link](); // persist changes to database

Parent topic: Modifying and creating API [45]

Check in/check out API


The check in/check out ScriptNode API features methods for check out, check in, and cancelling check out of working copies.
Note: If you want to record version history when using these methods, first add the cm:versionable aspect to a node.

checkout [76] The checkout methods perform checkouts of versionable nodes.


checkin [77] The checkin methods perform check in operations on working copy nodes.
cancelCheckout [78]cancelCheckout() cancels the check­out of a working copy document.
checkoutForUpload [79]checkoutForUpload() performs a checkout of the node for upload.
unlock [80]unlock() removes a lock on the node.

Parent topic: ScriptNode API [10]

checkout
The checkout methods perform checkouts of versionable nodes.
Parent topic: Check in/check out API [46]

checkout ()

checkout() this method performs a checkout of the node.

Returns

Returns the resulting working copy node.

Example
var workingCopy;
var node = [Link]("TEST_FILE_1.TXT");

[Link](true, true);

if ([Link]){

workingCopy = [Link]();
[Link] = "Add some content.";
[Link]("Added some content.");
}

checkout(destination)
checkout(destination) this method performs a check out of the node to the specified destination.

Parameters
destination
Destination for the checked out document working copy node.

Returns

Returns the resulting working copy node.

checkin
The checkin methods perform check in operations on working copy nodes.
Parent topic: Check in/check out API [46]

checkin()

checkin() this method performs a check in operation on a working copy node. It copies the current state of the working copy to the original node
(including any content updated in the working node). This method can only be called on a working copy node.

Returns

Returns the original node that was previously checked out.

checkin(description)

checkin(description) this method performs a check in operation on a working copy node applying the specified version history note text.

Parameters
description
A version history note. A description of the change made.

Returns

Returns the original node that was previously checked out.

Example
var workingCopy;
var node = [Link]("TEST_FILE_1.TXT");

[Link](true, true);

if ([Link]){

workingCopy = [Link]();
[Link] = "Add some content.";
[Link]("Added some content.");
}

checkin(description, majorVersion)

checkin(description, majorVersion) this method performs a check in operation on a working copy node.

It applies the specified version history note text and as a major or minor version increment as required.

Parameters
description
A version history note. A description of the change made.
majorVersion
True to save as a major version increment, false for minor version

Returns

Returns the original node that was previously checked out.


cancelCheckout
cancelCheckout() cancels the check­out of a working copy document.

The working copy is deleted and any changes made to it are lost.

Note: This method can only be called on a working copy node. Any reference to this working copy node should be discarded.

Returns
Returns the original node that was previously checked out.

Example
var workingCopy;
var node = [Link]("TEST_FILE_1.TXT");

[Link](true, true);

if ([Link]){

workingCopy = [Link]();
[Link] = "Add some content.";

// changed mind

node = [Link]();

Parent topic: Check in/check out API [46]

checkoutForUpload
checkoutForUpload() performs a checkout of the node for upload.

Returns
Returns the resulting working copy node.

Parent topic: Check in/check out API [46]

unlock
unlock()removes a lock on the node.
Parent topic: Check in/check out API [46]

Versions API
The Versions ScriptNode API provides several methods and properties for managing and retrieving the versions of a document.

Properties
isVersioned
A read­only Boolean property for determining if the document is versioned
versionHistory
A read­only property for listing all versions of the document in descending (version created) date order

Script Version Object [81] The Versions ScriptNode API provides methods that return ScriptVersion objects, for example, getVersion().
ScriptVersion objects have the following properties.
getVersion [82]getVersion(label) gets a specific version of a document identified by label.
createVersion [83]createVersion(history, major) this method creates a version snapshot of the current document.
ensureVersioningEnabled [84]ensureVersioningEnabled(autoVersion, autoVersionProps) ensures that this node has the cm:versionable
aspect applied to it, and that it has the initial version in the version store.
getVersionHistory [85]getVersionHistory() gets the version history for the current node.

Parent topic: ScriptNode API [10]

Script Version Object


The Versions ScriptNode API provides methods that return ScriptVersion objects, for example, getVersion(). ScriptVersion objects have the
following properties.

Properties
createdDate
A read­only property representing the date at which the version was created
creator
A read­only property representing the user name of the person who created the version
label
A read­only property representing the version label
type
A read­only property representing the version type (MAJOR, MINOR)
description
A read­only property representing the description (history comment) of the version
nodeRef
A read­only property representing the node reference of the document that was versioned
node
A read­only property representing the node as it was versioned

Parent topic: Versions API [47]

getVersion
getVersion(label) gets a specific version of a document identified by label.

Parameters
label
The version label of the node to get.

Returns
A ScriptVersion object representing the version of this node requested.

Example
var version;
var createdDate;
var creator;

var node = [Link]("TEST_FILE_1.TXT");

if ([Link]){
version = [Link]("1.0");
createdDate = [Link];
creator = [Link];
}

Parent topic: Versions API [47]

createVersion
createVersion(history, major) this method creates a version snapshot of the current document.

Note: this will add the cm:versionable aspect.

Parameters
history
Version history note. A description of the change made.
major
True to save as a major version increment, false for minor version.

Returns
Returns a ScriptVersion object for the new version of the document.

Parent topic: Versions API [47]


ensureVersioningEnabled
ensureVersioningEnabled(autoVersion, autoVersionProps) ensures that this node has the cm:versionable aspect applied to it, and that it has the
initial version in the version store.

Calling this on a versioned node with a version store entry will have no effect. Calling this on a newly uploaded share node will have versioning
enabled for it.

Parameters
autoVersion
If set to true auto versioning will also be applied if the cm:versionable aspect is applied.
autoVersionProps
If set to true auto versioning of properties will also be applied, if the cm:versionable aspect is applied.

Returns
ScriptVersion

Example
var version;
var createdDate;
var creator;

var node = [Link]("TEST_FILE_999.TXT");

[Link](true, true);

if ([Link]){
version = [Link]("1.0");
createdDate = [Link];
creator = [Link];
}

Parent topic: Versions API [47]

getVersionHistory
getVersionHistory() gets the version history for the current node.

Returns
Version history as a list of ScriptVersion objects.

Example

var versionHistory;
var revisionDates = new Array();

var node = [Link]("TEST_FILE_1.TXT");

[Link](true, true);

if ([Link]){
versionHistory = [Link]();

for (var i in versionHistory){


[Link](versionHistory[i].createdDate);
}
}

Parent topic: Versions API [47]

Content API
The Content API provides several properties to manipulate node content directly. The content can also be manipulated using the
ScriptContentData API.

Properties
content
A read/write value that represents the content as a string
mimetype
A read/write value representing the MIME type of the content
size
A read­only long value that represents the size (in bytes) of the content
url
A read­only string representing the download URL for the content
downloadUrl
A read­only string representing the download (as attachment) URL for the content
webdavUrl
A read­only string representing the webdav URL for the content

Parent topic: ScriptNode API [10]

ScriptContentData API
The ScriptContentData API provides several methods and properties related to node properties of type d:content; for example,
[Link].

Properties
content
A read/write value that represents the content as a string
mimetype
Guess and apply the MIME type to the content based on the file name
encoding
A read/write string value that represents the encoding of the content
size
A read­only long value that represents the size (in bytes) of the content
url
A read­only string representing the download URL for the content
downloadUrl
A read­only string representing the download (as attachment) URL for the content

write [86]write(content) copies the content from the specified ScriptContent.


guessMimetype [87]guessMimetype(filename) guesses and applies the MIME type to the content based on the given file name.
guessEncoding [88]guessEncoding() guesses and applies the encoding to the content based on the current content. It uses the
ContentCharsetFinder service.
getInputStream [89]getInputStream() returns the input stream for the underlying ScriptContentData object.
getReader [90]getReader() returns the reader for the input stream of the underlying ScriptContentData object.

Parent topic: ScriptNode API [10]

write
write(content)copies the content from the specified ScriptContent.
Parent topic: ScriptContentData API [49]

write(content)

Sets the content stream from another content object.

Parameters

content
The source ScriptContentData object.

Example
var sourceFilename = "TEST_FILE_1.TXT";
var destFilename = "TEST_FILE_2.TXT";

var sourceNode = [Link](sourceFilename);


var destNode = [Link](destFilename);

[Link] = "This is the SOURCE node content!";


[Link]([Link]);

write(content, applyMimetype, guessEncoding)


Sets the content stream from another content object.

Parameters
content
The source ScriptContentData object.
applyMimetype
If set to true, the mimetype will be set from the mimetype of the source ScriptContentData object. If false, the mimetype of the target is
unchanged.
guessEncoding
If true the method will attempt to determine the encoding from the source content stream. If false, the encoding as set in the source
content object will be used.

Example
// use mimetype and encoding from source node
[Link]([Link], true, false);

write(inputStream)

Sets the content stream from a source inputStream.

Parameters

inputStream
The source inputStream.

Example
// use source node content stream
[Link]([Link]());

guessMimetype
guessMimetype(filename) guesses and applies the MIME type to the content based on the given file name.

Parameters
filename
The file name of the content

Parent topic: ScriptContentData API [49]

guessEncoding
guessEncoding() guesses and applies the encoding to the content based on the current content. It uses the ContentCharsetFinder service.

Parameters
none

Parent topic: ScriptContentData API [49]

getInputStream
getInputStream() returns the input stream for the underlying ScriptContentData object.

Parameters
none

Returns
Input stream of the underlying ScriptContentData object.

Parent topic: ScriptContentData API [49]


getReader
getReader() returns the reader for the input stream of the underlying ScriptContentData object.

Parameters
none

Returns
The reader for the input stream of the underlying ScriptContentData object.

Parent topic: ScriptContentData API [49]

Transformation API
The Transformation API provides document, image, and FreeMarker template processing services in Alfresco.

transformDocument [91] The transformDocument methods use the document transformation services in Alfresco.
transformImage [92] The transformImage methods use the image transformation services in Alfresco.
processTemplate [93] The processTemplate methods use the FreeMarker template processing services in Alfresco.

Parent topic: ScriptNode API [10]

transformDocument
The transformDocument methods use the document transformation services in Alfresco.

The LibreOffice server is required for some document transformations.

Parent topic: Transformation API [50]

transformDocument(mimetype)

this method transforms a document to a new document MIME type format. It makes a copy of the document,
transformDocument(mimetype)
changes the extension to match the new MIME type, and applies the transformation.

Parameters

mimetype
The mimetype of the new document.

Returns

Returns the transformed document node if successful, or null if the transformation failed.

Example

// transform document type to HTML


var node = [Link]("TEST_1.TXT");

var transformedNode = [Link]("text/html");

transformDocument(mimetype, destination)

transformDocument(mimetype, destination) this method transforms a document to a new document MIME type format. It makes a copy of the
document in the specified destination folder, changes the extension to match the new MIME type, and applies the transformation.

Parameters

mimetype
The mimetype of the new document.

destination
The destination folder in which the new document will be placed.

Returns
Returns the transformed document node if successful, or null if the transformation failed.

Example
// transform document and place new document in destination folder
var node = [Link]("TEST_1.TXT");
var destDir = [Link]("TRANSFORMED_DOCS");

var transformedNode = [Link]("text/xml", destDir);

transformImage
The transformImage methods use the image transformation services in Alfresco.
Note: To use these services, the ImageMagick components must be installed and working correctly. For more detailed information on
ImageMagick, refer to the ImageMagick web site.
Parent topic: Transformation API [50]

transformImage(mimetype)

transformImage(mimetype) this method transforms an image to a new image format.

Parameters

mimetype
The mimetype the document will be transformed to.

Returns

Returns the transformed image node if successful, or null if the transformation failed.

Example
// transform JPEG image file to BMP
var node = [Link]("WIND_TURBINE.JPG");

var transformedNode = [Link]("image/bmp");

transformImage(mimetype, options)

transformImage(mimetype, options) this method transforms a document to a new document MIME type format. It copies the document, changes
the extension to match the new MIME type, and then applies the transformation. The transformed image node is returned if successful, or null
is returned if the transformation failed.

Parameters

mimetype
The mimetype the document will be transformed to.
options
Image convert command options.

Returns

Returns the transformed image node if successful, or null if the transformation failed.

transformImage(mimetype, destination)

this method transforms a document to a new document MIME type format. It copies the document,
transformImage(mimetype, destination)
changes the extension to match the new MIME type, and then applies the transformation.

Parameters
mimetype
The mimetype the document will be transformed to.
destination
The destination folder the transformed document will be output to.

Returns

Returns the transformed image node if successful, or null if the transformation failed.
Example
// transform image from JPEG to GIF and locate in destination folder
var node = [Link]("WIND_TURBINE.JPG");
var destDir = [Link]("TRANSFORMED_IMAGES");

var transformedNode = [Link]("image/gif", destDir);

transformImage(mimetype, options, destination)

transformImage(mimetype, options, destination) this method transforms an image to a new image format, applying the supplied ImageMagick
options. It copies the image document in the specified destination folder, changes the extension to match the new MIME type, and then applies
the transformation.

Parameters

mimetype
The mimetype the document will be transformed to.
options
Image convert command options.
destination
The destination folder the transformed document will be output to.

Returns
Returns the transformed image node if successful, or null if the transformation failed.

processTemplate
The processTemplate methods use the FreeMarker template processing services in Alfresco.
Parent topic: Transformation API [50]

processTemplate(template)

processTemplate(template) this method executes a FreeMarker template file against the node. The node is used as the context for the document
or space object in the templating default model.

Parameters

template
The node of the template to execute as a ScriptNode object.

Returns

Returns the transformed image node if successful, or null if the transformation failed.

processTemplate(template, args)

processTemplate(template, args) this method executes a FreeMarker template file against the node, passing the supplied array of name/value
pair arguments to the template. The node is used as the context for the document or space object in the templating default model.

Parameters
template
The node of the template to execute as a ScriptNode object.
args
An associative array containing the name­value pairs of arguments to be passed to the template.

Returns

Returns the result of the template execution as a string.

processTemplate(template)

processTemplate(template) this method executes a FreeMarker template file against the node. The node is used as the context for the document
or space object in the templating default model.

Parameters
template
The template to process passed as a string.

Returns
Returns the transformed image node if successful, or null if the transformation failed.

processTemplate(template, args)

processTemplate(template, args) this method executes a FreeMarker template file against the node, passing the supplied array of name/value
pair arguments to the template. The node is used as the context for the document or space object in the templating default model.

Parameters

template
The template to process passed as a string.
args
An associative array containing the name­value pairs of arguments to be passed to the template.

Returns

Returns the result of the template execution as a string.

Thumbnail API
A thumbnail is a transformation of content into a specified destination MIME type. This is most commonly an image of a particular size, but can
also be other things, for example, a Flash rendition. The ScriptNode class provides several methods for generating and handling thumbnails.

createThumbnail [94] The createThumbnail methods create a thumbnail based on the definition registered for the thumbnail name
provided.
getThumbnail [95]getThumbnail(thumbnailName) gets the given thumbnail for the content property.
getThumbnails [96]getThumbnails() gets all the thumbnails for a given node's content property.
getThumbnailDefinitions [97]getThumbnailDefinitions() returns the names of the thumbnail definitions that can be applied to the content
property of this node.
ScriptThumbnail Object [98] Certain thumbnail methods return ScriptThumbnail objects. These objects are an extension of the ScriptNode
object. ScriptThumbnail objects have a single method, update.

Parent topic: ScriptNode API [10]

createThumbnail
The createThumbnail methods create a thumbnail based on the definition registered for the thumbnail name provided.

If the thumbnail name has not been registered, there will be an error.

Parent topic: Thumbnail API [51]

createThumbnail(thumbnailName)

createThumbnail(thumbnailName,async) this method creates a thumbnail based on the definition registered for the thumbnail name provided.

If the thumbnail name has not been registered, there will be an error.

Parameters

thumbnailName
The thumbnail name. The thumbnail name corresponds to preset thumbnail details stored in the repository.

Returns

Returns the ScriptThumbnail object representing the newly created thumbnail.

createThumbnail(thumbnailName,async)

createThumbnail(thumbnailName,async) this method creates a thumbnail based on the definition registered for the thumbnail name provided.

If the thumbnail name has not been registered, there will be an error.

Parameters
thumbnailName
The thumbnail name. The thumbnail name corresponds to preset thumbnail details stored in the repository.
async
Optional parameter
False by default, true if the thumbnail is to be created asynchronously. When set to false, the method blocks until the thumbnail is created
and the newly created thumbnail is returned. If set to true, the method queues the creation of the thumbnail asynchronously and
immediately returns to the calling client with null.

Returns
Returns the ScriptThumbnail object representing the newly created thumbnail.

getThumbnail
getThumbnail(thumbnailName) gets the given thumbnail for the content property.

Parameters
thumbnailName
The thumbnail name. The thumbnail name corresponds to preset thumbnail details stored in the repository.

Returns
Returns a ScriptThumbnail object representing the specified thumbnail.
Parent topic: Thumbnail API [51]

getThumbnails
getThumbnails() gets all the thumbnails for a given node's content property.

Returns
Returns a list of ScriptThumbnail objects. This is empty if none are available.

Parent topic: Thumbnail API [51]

getThumbnailDefinitions
getThumbnailDefinitions() returns the names of the thumbnail definitions that can be applied to the content property of this node.

Thumbnail definitions only appear in this list if they can produce a thumbnail for the content found in the content property. This is determined by
looking at the MIME type of the content and the destination MIME type of the thumbnail.

Returns
Returns an array of thumbnail names that are valid for the current content type.

Parent topic: Thumbnail API [51]

ScriptThumbnail Object
Certain thumbnail methods return ScriptThumbnail objects. These objects are an extension of the ScriptNode object. ScriptThumbnail objects
have a single method, update.

update [99]update() updates all the thumbnails for a particular node.

Parent topic: Thumbnail API [51]

update
update() updates all the thumbnails for a particular node.

This method belongs to the ScriptThumbnail object, which extends the standard ScriptNode and represents a thumbnail object.

Parent topic: ScriptThumbnail Object [98]


Tagging API
A tag is a non­hierarchical keyword or term assigned to a piece of information.

Properties
tags
An array of tag name strings. If a string array of tags is applied to this property they will overwrite the tags currently applied to the node.
isTagScope
A boolean. If true, the node is a tag scope node and false otherwise.

clearTags [100]clearTags() deletes all the tags from the node.


addTag [101]addTag(tag) adds a single tag to a node.
addTags [102]addTags(tags) adds several tags to a node.
removeTag [103]removeTag(tag) removes the specified tag from a node.
removeTags [104]removeTags(tags) removes the specified tags from a node.
getTagScope [105]getTagScope() gets the nearest tag scope to this node by traversing up the parent hierarchy until one is found. If none is
found, null is returned.
setIsTagScope [106]setIsTagScope(boolean value)
childrenByTags [107]childrenByTags(tag) gets all children of the node that have the tag specified. The methods fetch the children of the
node in a deep (recursive) fashion.

Parent topic: ScriptNode API [10]

clearTags
clearTags()deletes all the tags from the node.
Parent topic: Tagging API [52]

addTag
addTag(tag) adds a single tag to a node.

Parameters
tag
The tag (as a string) to add to the node.

Returns
void

Parent topic: Tagging API [52]

addTags
addTags(tags) adds several tags to a node.

Parameters
tags
A string array containing the tags to add to the node.

Returns
void

Parent topic: Tagging API [52]

removeTag
removeTag(tag) removes the specified tag from a node.

Parameters
tag
The tag (as a string) to remove from the node.

Parent topic: Tagging API [52]

removeTags
removeTags(tags) removes the specified tags from a node.

Parameters
tags
A string array containing the tags to remove from the node.

Parent topic: Tagging API [52]

getTagScope
getTagScope() gets the nearest tag scope to this node by traversing up the parent hierarchy until one is found. If none is found, null is returned.

Returns
A TagScope object which represents the nearest tag scope, or null if one is not found.

Parent topic: Tagging API [52]

setIsTagScope
setIsTagScope(boolean value) sets whether this node is a tag scope or not.

Parameters
value
True if this node is a tag scope, false otherwise.

Returns
void

Parent topic: Tagging API [52]

childrenByTags
childrenByTags(tag) gets all children of the node that have the tag specified. The methods fetch the children of the node in a deep (recursive)
fashion.

Parameters
tag
A string representing the tag name.

Returns
An array of ScriptNode objects that corresponds to the children of the node with the specified tag.

Parent topic: Tagging API [52]

Actions API
The actions API provides a root level actions object that allows invocation of Alfresco actions registered with the repository.

Properties
The following Action object properties are available to use within scripts:
Action Object Property Read/write Description
registered Read­only An array of strings representing the actions available.

create [108]create(name) returns the ScriptAction object with the name specified.

Parent topic: Scripting API [3]

create
create(name) returns the ScriptAction object with the name specified.

Parameters
name
A string representing the name of the action to return a ScriptAction object for.

Returns
The ScriptAction object for the given action name, or null if the action name is not registered.

Parent topic: Actions API [11]

Classification API
The Classification API has two parts: manipulating classifications, and manipulating the categories they contain.
A root level classification object is provided to return category nodes. The CategoryNode objects returned from the methods are extended from
the standard JavaScript ScriptNode model to include category manipulation.

createRootCategory [109]createRootCategory(aspect, name) creates a root category.


getAllCategoryNodes [110]getAllCategoryNodes(aspect) gets an array of all the category nodes in the given classification.
getAllClassificationAspects [111]getAllClassificationAspects() gets all the aspects that define a classification. An array of aspect
QNames in prefix:localName form is returned.
getCategory [112]getCategory(catRef) returns a category node.
getCategoryUsage [113]getCategoryUsage(aspect, maxCount) returns categories with the most number of objects. The number of categories
returned is specified in maxCount.
getRootCategories [114]getRootCategories(aspect) returns an array of root category nodes for a given classification.
setStoreUrl [115]setStoreUrl(storeRef) sets the default store reference.
CategoryNode API [116] The CategoryNode objects returned from the classification object methods are extended from the standard
JavaScript ScriptNode model.

Parent topic: Scripting API [3]

createRootCategory
createRootCategory(aspect, name) creates a root category.

Parameters
aspect
The classification aspect.
name
Name of root category to create.

Returns
A category node

Example
Parent topic: Classification API [12]

getAllCategoryNodes
getAllCategoryNodes(aspect) gets an array of all the category nodes in the given classification.
Parameters
aspect
The classification aspect.

Returns
Returns an array of CategoryNode objects in the given classification.

Parent topic: Classification API [12]

getAllClassificationAspects
getAllClassificationAspects() gets all the aspects that define a classification. An array of aspect QNames in prefix:localName form is returned.

Returns
Returns an array of strings representing aspects as QNames.

Example
[Link] = [Link]();

The previous code would return aspects such as cm:taggable, cm:generalclassifiable, cm:classifiable.

Parent topic: Classification API [12]

getCategory
getCategory(catRef) returns a category node.

Parameters
catRef
The category node reference.

Returns
A category node.

Example
.

Parent topic: Classification API [12]

getCategoryUsage
getCategoryUsage(aspect, maxCount) returns categories with the most number of objects. The number of categories returned is specified in
maxCount.

Parameters
aspect
The classification aspect / category.
maxCount
The maximum number of categories to return.

Returns
Scriptable object containing the top categories.

Example
.

Parent topic: Classification API [12]

getRootCategories
getRootCategories(aspect) returns an array of root category nodes for a given classification.

Parameters
aspect
The classification aspect.

Returns
Array of root category nodes.

Example
[Link] = [Link]("cm:generalclassifiable");

The previous code snippet would return category node names such as:

Software Document Classification

Languages

Regions

Tags

Parent topic: Classification API [12]

setStoreUrl
setStoreUrl(storeRef) sets the default store reference.

Parameters
String storeRef
The default store reference.

Returns
void

Parent topic: Classification API [12]


Parent topic: People API [14]

CategoryNode API
The CategoryNode objects returned from the classification object methods are extended from the standard JavaScript ScriptNode model.

Properties
isCategory
Returns true if this is a category node, or false otherwise. This is supported by all nodes types.

categoryMembers
Gets an array of all the members of this category at any depth

subCategories
Gets an array of all the subcategories of this category at any depth

membersAndSubCategories
Gets an array of all the subcategories and members of this category at any depth

immediateCategoryMembers
Gets an array of all the immediate members of this category (only direct members of this category and not through sub categories).

immediateSubCategories
Gets an array of all the immediate subcategories of this category (only direct subcategories of this category and not through
subcategories)

immediateMembersAndSubCategories
Gets an array of all the immediate subcategories and members of this category (only direct subcategories and members of this category
and not through subcategories)

createSubCategory [117]createSubCategory(name) creates a new subcategory from the current category node.
removeCategory [118]removeCategory() deletes the current category node.
rename [119]rename(name) renames the current category node to the specified name.

Parent topic: Classification API [12]

createSubCategory
createSubCategory(name) creates a new subcategory from the current category node.

Parameters
name
Name of the category to create.

Returns
Returns a CategoryNode representing the new sub­category created.

Parent topic: CategoryNode API [116]

removeCategory
removeCategory()deletes the current category node.
Parent topic: CategoryNode API [116]

rename
rename(name) renames the current category node to the specified name.

Parameters
name
String representing the new name of the category node.

Parent topic: CategoryNode API [116]

Logging API
A root level logger object provides a number of methods to help debug scripts.

Properties
loggingEnabled
True if logging is enabled.
debugLoggingEnabled
True if debug logging is enabled.
infoLoggingEnabled
True if info logging is enabled.
warnLoggingEnabled
True if warn logging is enabled.
errorLoggingEnabled
True if error logging is enabled.
[Link]("Debug string")

log [120]log(string) writes a message string to the log.


warn [121]warn(string) writes a message string to the log.
info [122]info(string) writes a message string to the log.
error [123]error(string) writes a message string to the console.
debug [124]debug(string) writes a debug message string to the log.

Parent topic: Scripting API [3]

log
log(string) writes a message string to the log.

Parameters
string
A message string to write to the log.

Parent topic: Logging API [13]

warn
warn(string) writes a message string to the log.

Parameters
string
A message string to write to the log.

Parent topic: Logging API [13]

info
info(string) writes a message string to the log.

Parameters
string
A message string to write to the log.

Parent topic: Logging API [13]

error
error(string) writes a message string to the console.

Parameters
string
A message string to write to the log.

Parent topic: Logging API [13]

debug
debug(string) writes a debug message string to the log.

Parameters
string
A message string to write to the log.

Parent topic: Logging API [13]

People API
The People API provides access to Alfresco people and groups.

addAuthority [125]addAuthority(parentGroup, authority) adds an authority (User or Group ) to the specified parent group.
changePassword [126]changePassword(oldpassword, newpassword) changes the password for the current user only when the old password is
supplied.
createGroup [127] The createGroup methods are used to create groups.
createPerson [128]createPerson creates a person (cm:person) object.
deleteGroup [129]deleteGroup(group) removes a group from the system.
deletePerson [130] The deletePerson(username) method deletes a person with the given user name from the system.
disableAccount [131]disableAccount(userName) disables an enabled account. It can be invoked with Administrator authority only.
enableAccount [132]enableAccount(userName) enables a disabled account. It can be invoked with Administrator authority only.
getCapabilities [133]getCapabilities(person) returns a hash of the specified user's capabilities.
getContainerGroups [134]getContainerGroups(person) gets the groups that contain the specified authority.
getExcludeTenantFilter [135]getExcludeTenantFilter(person) returns a Boolean.
getGroup [136]getGroup(groupId) gets a group given the group ID.
getImmutableProperties [137]getImmutableProperties(username) returns a map of the person properties that are marked as immutable for
the given user.
getMembers [138]getMembers returns an array of people nodes belonging to the specified group (including all subgroups).
getPeople [139] The getPeople(...) methods get the collection of people stored in the repository.
getPeoplePaging [140]getPeoplePaging() gets the collection of people stored in the repository.
getPeopleEvaluationMode [141]ScriptNode getPeopleEvaluationMode(username) returns the permission evaluation mode.
getPerson [142]ScriptNode getPerson(username) returns a single (cm:person) node associated with the specified user name, or null if the
person does not exist.
getPersonFullName [143]ScriptNode getPersonFullName(username) avoids complete getProperties() retrieval for a cm:person when the script
only requires the full name of person.
isAccountEnabled [144]isAccountEnabled(userName) determines if the specified user's account is enabled.
isAdmin [145]isAdmin(person) determines if the specified user has Administrator authority.
isGuest [146]isGuest(person) determines if the specified user has Guest authority.
removeAuthority [147]removeAuthority(parentGroup, authority) removes an authority from a group.
setPassword [148]setPassword(userName, password) sets the password for the given user. It is executable with Administrator authority only.
setQuota [149]setQuota(person, quota) sets the quota content in bytes for the specified person. It can be invoked only by an Administrator
authority.
setStoreUrl [115]setStoreUrl(storeRef) sets the default store reference.

Parent topic: Scripting API [3]

addAuthority
addAuthority(parentGroup, authority) adds an authority (User or Group ) to the specified parent group.

Parameters
parentGroup
The node representing the group to add the user or group to.
authority
A node representing the user or group to add.

Example
The following example will add [Link] to the administrators group.

var group = [Link]("GROUP_ALFRESCO_ADMINISTRATORS");

if(group){

user = [Link]("[Link]");
try{
[Link](group, user);
}
catch (ex){
[Link] = "ABORT: Exception occurred: "+ex;
return;
}
}

If a probem occurs, for example the user cannot be found, an exception message will be generated such as the following:
ABORT: Exception occurred: JavaException: [Link]: Authority is a mandatory parameter

Parent topic: People API [14]

changePassword
changePassword(oldpassword, newpassword) changes the password for the current user only when the old password is supplied.

Parameters
oldpassword
A string representing the currently logged in user's current password.
newpassword
A string representing the currently logged in user's new password.

Example
[Link]("oldpwd", "newpwd");

Parent topic: People API [14]

createGroup
The createGroup methods are used to create groups.
Parent topic: People API [14]

createGroup(groupName)

createGroup(groupName) this method creates a new top­level where groupName is the unique group name to create.

Parameters

group
The unique group name to create

Example
var groupName = "TECH_WRITERS";
var newGroup = [Link]("GROUP_"+groupName);
if(!newGroup){
newGroup = [Link](groupName);
}

createGroup(parentGroup,groupName)

createGroup(parentGroup, groupName) this method creates a new group as a child of the specified parent group node. This can be null for a top­
level group.

Parameters

parentGroup
The parent group
groupName
The group name

Example
var parentGroupName = "TECH_WRITERS";
var parentGroup = [Link]("GROUP_"+parentGroupName);
var subGroup = "TECH_WRITER_ELITE"; // do not prefix with GROUP_

if(parentGroup){
newGroup = [Link](parentGroup, subGroup);
[Link] = newGroup;
}

createPerson
createPersoncreates a person (cm:person) object.
Parent topic: People API [14]

createPerson(username)

createPerson(username) creates a person (cm:person) with the given user name.

Parameters

userName
A string representing the user name for the user to be created.
Returns

Returns the person node created or null if the user name already exists.

createPerson(userName, firstName, lastName, emailAddress)

createPerson(userName, firstName, lastName, emailAddress) creates a person (cm:person) with a generated user name.

Parameters

userName
A string representing the username for the user to be created.
firstName
A string representing the user's first name.
lastName
A string representing the user's last name.
emailAddress
A string representing the user's email address.

Returns
Returns the person node created or null if the user cannot be created.

createPerson(username, firstName, lastName, emailAddress, password, setAccountEnabled)

createPerson(username, firstName, lastName, emailAddress, password, setAccountEnabled) creates a person (cm:person) with a generated user
name.

Parameters

userName
A string representing the username for the user to be created.
firstName
A string representing the user's first name.
lastName
A string representing the user's last name.
emailAddress
A string representing the user's email address.
setAccountEnabled
A boolean. Set to true to create an enabled user account. Set to false to create a disabled user account.

Returns

Returns the person node created or null if the user cannot be created.

createPerson(username, firstName, lastName, emailAddress, password, setAccountEnabled,


notifyByEmail)

createPerson(username, firstName, lastName, emailAddress, password, setAccountEnabled, notifyByEmail) creates a person (cm:person) with a
generated user name.

Parameters
userName
A string representing the username for the user to be created.
firstName
A string representing the user's first name.
lastName
A string representing the user's last name.
emailAddress
A string representing the user's email address.
setAccountEnabled
A boolean. Set to true to create an enabled user account. Set to false to create a disabled user account.
notifyByEmail
A boolean. Set to true to have an automated email sent to the user's account when the account is created. This only works if the
username and password are provided. If set to false no email will be sent.

Returns

Returns the person node created or null if the user cannot be created.
Example
var testUser = [Link]("[Link]", "Joe", "User", "[Link]@[Link]", "password", true, true);
if (testUser){
// user account created
}

deleteGroup
deleteGroup(group) removes a group from the system.

Parameters
group
The group to delete.

Example
var node = [Link]("GROUP_TECH_WRITERS");

if(node){
[Link](node);
}

Parent topic: People API [14]

deletePerson
The deletePerson(username) method deletes a person with the given user name from the system.

Parameters
username
The user name of the person to delete.

Example
[Link]("[Link]");

Parent topic: People API [14]

disableAccount
disables an enabled account. It can be invoked with Administrator authority only.
disableAccount(userName)
Note: This procedure works for alfrescoNtlm users only.

Parameters
userName
A string representing the user name of the user whose account is to be disabled.

Example
The following code snippet toggles the user account status:
if([Link]("Joe")){
[Link]("Joe");
}
else{
[Link]("Joe");
}

Parent topic: People API [14]

enableAccount
enableAccount(userName) enables a disabled account. It can be invoked with Administrator authority only.
Parameters
userName
A string representing the user name of the user whose account is to be enabled.

Example
The following code snippet toggles the user account status:

if([Link]("Joe")){
[Link]("Joe");
}
else{
[Link]("Joe");
}

Parent topic: People API [14]

getCapabilities
getCapabilities(person) returns a hash of the specified user's capabilities.

Parameters
person
A node representing the user whose capabilities are to be fetched.

Returns
A <string, boolean> hash containing the capabilities of the user. For example, isMutable, isGuest, isAdmin and their boolean states will be
returned.

Example
The following code snippet returns a hash containing the capabilities of the admin user:
var person = [Link]("admin");

if (person){
[Link] = [Link](person);
}

The capabilities returned would be as follows:

isMutable: TRUE

isGuest: FALSE

isAdmin: TRUE

Parent topic: People API [14]

getContainerGroups
getContainerGroups(person) gets the groups that contain the specified authority.

Parameters
person
The user (cm:person) to get the containing groups for.

Example
The following code returns a list of groups that abeecher is a member of:
var user = [Link]("abeecher");

if(user){
[Link] = [Link](user);
}
Parent topic: People API [14]

getExcludeTenantFilter
getExcludeTenantFilter(person) returns a Boolean.

Parameters
None

Returns
A boolean.

Parent topic: People API [14]

getGroup
getGroup(groupId) gets a group given the group ID.

Parameters
groupId
A string representing the groupId of the group to return.

Returns
Returns a ScriptGroup object, or null if the group cannot be found.

Example

function main()
{
//
// Get the person details
//

if (([Link]("userName")) || ([Link]("userName").length() == 0))


{
[Link](status.STATUS_BAD_REQUEST, "User name missing when creating person");
return;
}

if (([Link]("firstName")) || ([Link]("firstName").length() == 0))


{
[Link](status.STATUS_BAD_REQUEST, "First name missing when creating person");
return;
}

if (([Link]("email")) || ([Link]("email").length() == 0))


{
[Link](status.STATUS_BAD_REQUEST, "Email missing when creating person");
return;
}

var password = "password";


if ([Link]("password"))
{
password = [Link]("password");
}

// Create the person with the supplied user name


var userName = [Link]("userName");
var enableAccount = (([Link]("disableAccount") && [Link]("disableAccount")) == false);
var person = [Link](userName, [Link]("firstName"), [Link]("lastName"), [Link]("email"), password, enableAccount);

// return error message if a person with that user name could not be created
if (person === null)
{
[Link](status.STATUS_CONFLICT, "User name already exists: " + userName);
return;
}

// assign values to the person's properties


if ([Link]("title"))
{
[Link]["title"] = [Link]("title");
}
if ([Link]("organisation"))
{
[Link]["organization"] = [Link]("organisation");
}
if ([Link]("jobtitle"))
{
[Link]["jobtitle"] = [Link]("jobtitle");
}
[Link]();

// set quota if any ‐ note that only Admin can set this and will be ignored otherwise
var quota = ([Link]("quota") ? [Link]("quota") : ‐1);
[Link](person, [Link]());

// apply groups if supplied ‐ note that only Admin can successfully do this
if ([Link]("groups"))
{
var groups = [Link]("groups");
for (var index=0; index<[Link](); index++)
{
var groupId = [Link](index);
var group = [Link](groupId);
if (group != null)
{
[Link](group, person);
}
}
}

// Put the created person into the model


[Link] = person;
}

main();

Parent topic: People API [14]

getImmutableProperties
getImmutableProperties(username) returns a map of the person properties that are marked as immutable for the given user.

This enables a script to interrogate which properties are dealt with by an external system such as LDAP and should not be mutable in any
client UI.

Parameters
username
A string representing the username of the user whose immutable properties are to be fetched.

Returns
A ScriptableHashMap containing the immutable properties of the specified user.

Example
var person = [Link]("abeecher");

if (person){
[Link] = [Link](person);
}

Parent topic: People API [14]

getMembers
getMembersreturns an array of people nodes belonging to the specified group (including all subgroups).
Parent topic: People API [14]

getMembers

getMembers(group) gets specified group members.

Parameters
group
A node representing the group whose members will be fetched.

Returns
Returns an array of people nodes belonging to the specified group (including all subgroups).

Example

The following code would fetch all members of the administrators group and any subgroups.

var node = [Link]("GROUP_ALFRESCO_ADMINISTRATORS");

if(node){
[Link] = [Link](node);
}

getMembers

getMembers(group, recurse) gets specified group members. Will not recurse into subgroups if recurse is set to false.

Parameters

group
A node representing the group whose members will be fetched.
recurse
Set to true to recurse into subgroups. Set to false to turn off recursion.

Returns

Returns an array of people nodes belonging to the specified group or people of subgroups if recurse was set to true.

Example

The following code would fetch all members of the administrators group, but not the members of any subgroups.
var node = [Link]("GROUP_ALFRESCO_ADMINISTRATORS");

if(node){
[Link] = [Link](node, false);
}

getPeople
The getPeople(...) methods get the collection of people stored in the repository.
Parent topic: People API [14]

getPeople(filter)

getPeople(filter) get the collection of people stored in the repository.

An optional filter query can be provided by which to filter the people collection. Space separates the query terms, for example "john bob" will
find all users whose first or second names contain the strings "john" or "bob".

CAUTION:
This method is deprecated in version 4.0 and above.

Parameters

filter
This is a query string by which to filter the collection of people. If null then all people stored in the repository are returned.

Returns

Returns an array of NodeRefs.

Example

var user;
var nodes = [Link](null);
for each(var node in nodes)
{
[Link](node);
user = [Link](node);
[Link]([Link]["cm:userName"] + " '"
+ [Link]["cm:firstName"] + "' '"
+ [Link]["cm:lastName"] + "'");
}

getPeople(filter, maxResults)

getPeople(filter, maxResults) get the collection of people stored in the repository.

An optional filter query can be provided by which to filter the people collection. Space separates the query terms, for example "john bob" will
find all users whose first or second names contain the strings "john" or "bob".

Parameters
filter
This is a query string by which to filter the collection of people. If null then all people stored in the repository are returned.
maxResults
The maximum number of results to return. Returns all results if this value is set to be less than or equal to zero.

Returns

Returns an array of NodeRefs.

Example

The following snippet would return all users whose first or last names contained the string "fred". The results are limited to a maximum of 10
results:

[Link] = [Link]("fred", 10);

getPeople(filter, maxResults, sortBy, sortAsc)

getPeople(filter, maxResults, sortBy, sortAsc) get the collection of people stored in the repository.

An optional filter query can be provided by which to filter the people collection. Space separates the query terms, for example "john bob" will
find all users whose first or second names contain the strings "john" or "bob". This method supports sorting by specifying sortBy and sortAsc
parameters.

Parameters
filter
This is a query string by which to filter the collection of people. If null then all people stored in the repository are returned.
maxResults
The maximum number of results to return. Returns all results if this value is set to be less than or equal to zero.
sortBy
The field for sorting.
sortAsc
Set to true to sort results in ascending order.

Returns

Returns an array of NodeRefs.

Example
The following snippet would return all users whose first or last names contained the string "fred", sorted in ascending order on lastName. The
results are limited to a maximum of 10 results:
[Link] = [Link]("fred", 10, "lastName", true);

getPeoplePaging
getPeoplePaging() gets the collection of people stored in the repository.

Parameters
filter
This is a query string by which to filter the collection of people. If null then all people stored in the repository are returned.
pagingRequest
A ScriptPagingDetails object.
sortBy
The field for sorting.
sortAsc
Set to true to sort results in ascending order.

Returns
Returns a collection of people objects as a JavaScript array, with Paging.

Example
Parent topic: People API [14]

getPeopleEvaluationMode
ScriptNode getPeopleEvaluationMode(username) returns the permission evaluation mode.

Parameters
None

Returns
Permission evaluation mode.

Parent topic: People API [14]

getPerson
ScriptNode getPerson(username) returns a single (cm:person) node associated with the specified user name, or null if the person does not exist.

Parameters
username
A string representing the user name for the user who is being fetched.

Returns
A node representing the user requested, or null if the user name cannot be found.

Example
The following code snippet returns the node object for the user with the username abeecher:
[Link] = [Link]("abeecher");

Parent topic: People API [14]

getPersonFullName
ScriptNode getPersonFullName(username) avoids complete getProperties() retrieval for a cm:person when the script only requires the full name of
person.

Parameters
username
A string representing the user name of the user for which to return the full name.

Returns
Full name of the person or null if the user does not exist in the system.

Example
The following code snippet returns the full name for the user with the username abeecher:
[Link] = [Link]("abeecher");

Parent topic: People API [14]

isAccountEnabled
isAccountEnabled(userName) determines if the specified user's account is enabled.

Parameters
userName
A string representing the user name of the user whose account is to be checked.

Returns
Returns true if the specified user account is enabled, false if the account is currently disabled.

Example
The following code snippet toggles the user account status:
if([Link]("Joe")){
[Link]("Joe");
}
else{
[Link]("Joe");
}

Parent topic: People API [14]

isAdmin
isAdmin(person) determines if the specified user has Administrator authority.

Parameters
person
A node representing the user to check.

Returns
Returns true if the specified user is an Administrator authority.

Example
var userName = "abeecher";

var user = [Link](userName);

if(user){
[Link] = [Link](user);
[Link] = userName;
}

Parent topic: People API [14]

isGuest
isGuest(person) determines if the specified user has Guest authority.

Parameters
person
A node representing the user to check.

Returns
Returns true if the specified user is logged in as a guest.

Example
var userName = "abeecher";

var user = [Link](userName);

if(user){
[Link] = [Link](user);
[Link] = userName;
}

Parent topic: People API [14]

removeAuthority
removeAuthority(parentGroup, authority) removes an authority from a group.

Parameters
parentGroup
The node representing the group to remove the user or group from.
authority
A node representing the user or group to remove.

Example
The following code will remove the user abeecher from the test group.
var group = [Link]("GROUP_TEST");

if(group){

user = [Link]("abeecher");
try{
[Link](group, user);
}
catch (ex){
[Link] = "ABORT: Exception occurred: "+ex;
return;
}
}

If a probem occurs, for example the user cannot be found, an exception message will be generated such as the following:
ABORT: Exception occurred: JavaException: [Link]: Authority is a mandatory parameter

Parent topic: People API [14]

setPassword
setPassword(userName, password) sets the password for the given user. It is executable with Administrator authority only.

Parameters
userName
A string representing the user name of the user to set the password for.
password
A string representing the password to assign for the user specified.

Example
[Link]("[Link]", "newpwd");

Parent topic: People API [14]

setQuota
setQuota(person, quota) sets the quota content in bytes for the specified person. It can be invoked only by an Administrator authority.

Parameters
person
A node representing the user to set the quota for.
quota
A string representing the quota in bytes to allocate to the specified user. A value of ­1 means no quota is set.

Example
The following code sets the quota to 10 MB for the user abeecher:
var userName = "abeecher";
var user = [Link](userName);
if (user){
[Link](user, "10240000"); // 10 MB
}

Parent topic: People API [14]

setStoreUrl
setStoreUrl(storeRef) sets the default store reference.

Parameters
String storeRef
The default store reference.

Returns
void

Parent topic: Classification API [12]


Parent topic: People API [14]

ScriptAction API
A ScriptAction represents an Alfresco action registered within the repository.

Properties
name
Returns the name of the action
parameters
An associative array (map) of the parameters for the action

execute [150] The execute() methods execute the action against the specified node.
executeAsynchronously [151]executeAsynchronously(node) executes the action against the specified node asynchronously.

Parent topic: Scripting API [3]

execute
The execute() methods execute the action against the specified node.
Parent topic: ScriptAction API [15]

execute(node)

execute(node) executes the action against the specified node.

The action (and its parameters) can be reused against many nodes by repeatedly invoking execute. Between invocations, the parameters of
the action can be changed.

Parameters

node
The node on which to execute the action.

Example
Executing the mail action:

// create mail action


var mail = [Link]("mail");
[Link] = "davidc@[Link]";
[Link] = "Hello from JavaScript";
[Link] = "davidc@[Link]";
[Link] = [Link]
("Company Home/Data Dictionary/Email Templates/notify_user_email.ftl");
[Link] = "some text, in case template is not found";
// execute action against a document
[Link](doc);

execute(node, readOnly, newTxn)

execute(node, readOnly, newTxn) executes the action against the specified node.

The action (and its parameters) can be reused against many nodes by repeatedly invoking execute. Between invocations, the parameters of
the action can be changed.

Parameters
node
The node on which to execute the action.
readOnly
Set to true to start a read­only transaction, false otherwise.
newTxn
Set to true to start a new transaction, false to use the existing transaction.

execute(nodeRef)

execute(nodeRef) executes the action against the specified node.

The action (and its parameters) can be reused against many nodes by repeatedly invoking execute. Between invocations, the parameters of
the action can be changed.

Parameters

nodeRef
The node on which to execute the action.

execute(nodeRef, readOnly, newTxn)

execute(nodeRef, readOnly, newTxn) executes the action against the specified node.

The action (and its parameters) can be reused against many nodes by repeatedly invoking execute. Between invocations, the parameters of
the action can be changed.

Parameters

nodeRef
The node on which to execute the action.
readOnly
Set to true to start a read­only transaction, false otherwise.
newTxn
Set to true to start a new transaction, false to use the existing transaction.

executeAsynchronously
executeAsynchronously(node) executes the action against the specified node asynchronously.

The action (and its parameters) can be reused against many nodes by repeatedly invoking execute. Between invocations, the parameters of
the action can be changed.

When called, this method returns immediately, with the action executing in a separate thread.

Parameters
node
The node on which to execute the action.

Parent topic: ScriptAction API [15]


Search API
The Search API provides direct access to repository level search results and Saved Search results through the search root scope object.

Local searches can be performed using the ScriptNode APIs childByNamePath and childByXPath. Like the various node objects, the search object
is part of the root scope.

findNode [152]findNode methods allow you to search for a single node by node reference object, or node reference string. By default the
method assumes you are searching for a node that is a descendent of CompanyHome.
ISO9075Decode [153]ISO9075Decode(string value) is a helper to decode a ISO9075­encoded string for Lucene PATH statements.
ISO9075Encode [154]ISO9075Encode(string value) is a helper to encode a value into ISO9075­encoded format for Lucene PATH
statements.
isValidXpathQuery [155]isValidXpathQuery(query) checks the validity of an XPath query string.
luceneSearch [156] The luceneSearch methods provide search operations using the Lucene search syntax.
query [157]query(search) performs a search on ScriptNode objects.
savedSearch [158]savedSearch(node) returns an array of ScriptNode objects that were found by executing the Saved Search referenced by
the supplied node object. The node object contains the XML that represents the saved search.
selectNodes [159] The selectNodes methods perform an XPath search and return a list of found nodes.
tagSearch [160]tagSearch(store, tag) performs a search on a given tag in a given store.
xpathSearch [161]xpathSearch(xpath) performs an XPath search.

Parent topic: Scripting API [3]

findNode
findNodemethods allow you to search for a single node by node reference object, or node reference string. By default the method assumes you
are searching for a node that is a descendent of CompanyHome.
Parent topic: Search API [16]

findNode(noderef)

findNode(noderef)

This method returns a single ScriptNode as specified by the NodeRef object for that node.

Parameters

noderef
Node reference of the node to find.

Returns

Returns a single ScriptNode object, or null if the search failed.

Example
var foundNode = [Link](nodeRef);

findNode(noderef)

findNode(noderef)

This method returns a single ScriptNode as specified by the string form of the NodeRef for that node, null is returned if the search failed.

Parameters

noderef
A node reference as a string.

Returns

Returns a single ScriptNode, or null if the search failed.

Example

var foundNode = null;


if ([Link](nodeRefString)){

foundNode = [Link](nodeRefString);
...
}
findNode(referenceType, reference)

findNode(referenceType, reference)

Helper to convert a Web Script Request URL to a NodeRef.

Parameters
referenceType
The reference type. The reference type can be one of:

node
path

reference
The reference elements supplied depend on the reference type:

node ­ {store_type}/{store_id}/{node_id} — resolve to node through its node reference


path ­ {store_type}/{store_id}/{path} — resolve to node through its display path

Returns

Returns a single ScriptNode, or null if the search failed.

Example
var referenceType = "node";
// Store type, store id, node id
var reference = ["workspace", "SpacesStore", "78eb920f‐fd46‐41ee‐9fdb‐099e96da8349"];
var foundNode = [Link](referenceType, reference);

var referenceType = "path";


// store type, store id, display path
var reference = ["workspace", "SpacesStore", "Company Home/dir1/dir2","TEST_FILE_1.TXT"];
var foundNode = [Link](referenceType, reference);

ISO9075Decode
ISO9075Decode(string value) is a helper to decode a ISO9075­encoded string for Lucene PATH statements.

Parameters
string
The string to decode.

Returns
Returns a decoded string.

Example
The following code:

var rawString = "//test:123 DIR/[Link] @";


var encodedString = search.ISO9075Encode(rawString);
var decodedString = search.ISO9075Decode(encodedString);

Would result in the following strings:

rawString: //test:123 DIR/[Link] @


encodedString: _x002f__x002f_test_x003a_123_x0020_DIR_x002f_FILE.TXT_x0020__x0040_
decodedString: //test:123 DIR/[Link] @

The following code:


var rawString = "@cm\:name:\"banana\"";
var encodedString = search.ISO9075Encode(rawString);
var decodedString = search.ISO9075Decode(encodedString);

Would result in the following strings:


rawString: @cm:name:"banana"
encodedString: _x0040_cm_x003a_name_x003a__x0022_banana_x0022_
decodedString: @cm:name:"banana"

Parent topic: Search API [16]

ISO9075Encode
ISO9075Encode(string value) is a helper to encode a value into ISO9075­encoded format for Lucene PATH statements.

Parameters
string
The string to encode. Characters within the string that need to be encoded to ISO9075 will take the format _xDDDD_, where DDDD is the
hex value of the character.

Returns
Returns a ISO9075 encoded string.

Example
The following code:
var rawString = "//test:123 DIR/[Link] @";
var encodedString = search.ISO9075Encode(rawString);
var decodedString = search.ISO9075Decode(encodedString);

Would result in the following strings:


rawString: //test:123 DIR/[Link] @
encodedString: _x002f__x002f_test_x003a_123_x0020_DIR_x002f_FILE.TXT_x0020__x0040_
decodedString: //test:123 DIR/[Link] @

The following code:

var rawString = "@cm\:name:\"banana\"";


var encodedString = search.ISO9075Encode(rawString);
var decodedString = search.ISO9075Decode(encodedString);

Would result in the following strings:

rawString: @cm:name:"banana"
encodedString: _x0040_cm_x003a_name_x003a__x0022_banana_x0022_
decodedString: @cm:name:"banana"

Parent topic: Search API [16]

isValidXpathQuery
isValidXpathQuery(query) checks the validity of an XPath query string.

Parameters
query

The XPath query string to check.

Returns
Returns true is the query is a valid XPath query string, false otherwise.

Example
The method can be used to check the validity of a XPath query prior to use:

if ([Link](query)){
nodes = [Link](query);
}
else {
// ...
}

Parent topic: Search API [16]

luceneSearch
The luceneSearch methods provide search operations using the Lucene search syntax.
Parent topic: Search API [16]

luceneSearch(search)

luceneSearch(search) this method performs a full­text search.

Parameters

search
The search terms and operators that represent the Lucene search phrase.

Returns

Returns an array of ScriptNode objects that were found by the Alfresco repository Lucene search.

Example

var nodes = [Link]("TEXT:alfresco");

luceneSearch(store, search)

luceneSearch(store, search) this method performs a Lucene search in a given store.

Parameters
store
The given store, for example workspace://SpacesStore.
search
The search terms and operators that represent the Lucene search phrase.

Returns

Returns an array of ScriptNode objects that were found by the Alfresco repository Lucene search in the given store.

Example

var nodes = [Link]("workspace://SpacesStore", "TEXT:foo");

luceneSearch(search, sortColumn, asc)

luceneSearch(search, sortColumn, asc) this method performs a Lucene search by property and a specified sort order.

Parameters
search
The search terms and operators that represent the Lucene search phrase.
sortColumn
The property name to sort on.
asc
The sort order. If set to true the results are ordered in ascending order based on the property specified. If false the results are sorted in
descending order.

Returns

Returns an array of ScriptNode objects satisfying the search criteria sorted by the specified sortColumn and asc.

Example
var nodes = [Link]("TEXT:alfresco", "@cm:modified", false);

luceneSearch(store, search, sortColumn, asc)


luceneSearch(store, search, sortColumn, asc)

This method performs a Lucene search by property and a specified sort order in the given store.

Parameters
store
The given store
search
The search terms and operators that represent the Lucene search phrase.
sortColumn
The property name to sort on
asc
The sort order. If set to true the results are ordered in ascending order based on the property specified. If false the results are sorted in
descending order.

Returns

Returns an array of ScriptNode objects satisfying the search criteria and sorted by the specified sortColumn and asc in the given store.

Example
var nodes = [Link]("workspace://SpacesStore", "TEXT:alfresco", "@cm:modified", true);

luceneSearch(search, sortColumn, asc, max)

luceneSearch(search, sortColumn, asc, max) this method performs a Lucene search by property and a specified sort order in the specified store.
The number of results returned can be limited.

Parameters

search
The search terms and operators that represent the Lucene search phrase.
sortColumn
The property name to sort on
asc
The sort order. If set to true the results are ordered in ascending order based on the property specified. If false the results are sorted in
descending order.
max
The maximun number of items to return in the search results.

Returns

Returns an array of ScriptNode objects satisfying the search criteria and sorted by the specified sortColumn and asc. The results are limited to the
number specified by the max parameter.

Example
var nodes = [Link]("TEXT:alfresco", "@cm:modified", true, 50);

luceneSearch(store, search, sortColumn, asc, max)

luceneSearch(store, search, sortColumn, asc, max) this method performs a Lucene search by property and a specified sort order in the give
store.

Parameters

store
The given store
search
The search terms and operators that represent the Lucene search phrase.
sortColumn
The property name to sort on
asc
The sort order. If set to true the results are ordered in ascending order based on the property specified. If false the results are sorted in
descending order.
max
The maximun number of items to return in the search results.

Returns

Returns an array of ScriptNode objects satisfying the search criteria and sorted by the specified sortColumn and asc in the given store. Results
are limited to the number specified by the parameter max.

Example
var nodes = [Link]("workspace://SpacesStore", "TEXT:alfresco", "@cm:modified", true, 50);

query
query(search) performs a search on ScriptNode objects.

Parameters
search

The search object. The search object is defined as follows:


search
{
query: string, mandatory, in appropriate format and encoded for the given language
store: string, optional, defaults to 'workspace://SpacesStore'
language: string, optional, one of: lucene, xpath, jcr‐xpath, fts‐alfresco ‐ defaults to 'lucene'
templates: [], optional, Array of query language template objects (see below) ‐ if supported by the language
sort: [], optional, Array of sort column objects (see below) ‐ if supported by the language
page: object, optional, paging information object (see below) ‐ if supported by the language
namespace: string, optional, the default namespace for properties
defaultField: string, optional, the default field for query elements when not explicit in the query
onerror: string optional, result on error ‐ one of: exception, no‐results ‐ defaults to 'exception'
}

sort
{
column: string, mandatory, sort column in appropriate format for the language
ascending: boolean optional, defaults to false
}

page
{
maxItems: int, optional, max number of items to return in result set
skipCount: int optional, number of items to skip over before returning results
}

template
{
field: string, mandatory, custom field name for the template
template: string mandatory, query template replacement for the template
}

Returns
Returns an array of ScriptNode objects representing the search results.

Example
The search object defines the search to be executed as is constructed in this way:

The search definition object can be as simple to use as:

var results = [Link]({query: "TEXT:alfresco"});

Or as richly defined as:

var sort1 =
{
column: "@{[Link]
ascending: false
};

var sort2 =
{
column: "@{[Link]
ascending: false
};

var paging =
{
maxItems: 100,
skipCount: 0
};
var def =
{
query: "cm:name:test*",
store: "workspace://SpacesStore",
language: "fts‐alfresco",
sort: [sort1, sort2],
page: paging
};

var results = [Link](def);

This interface supports multi­column sorting and any of the Alfresco search languages. Future versions of the API will allow the search
definition objects to be extended with additional properties while maintaining backward compatibility.

Parent topic: Search API [16]

savedSearch
savedSearch(node)returns an array of ScriptNode objects that were found by executing the Saved Search referenced by the supplied node object.
The node object contains the XML that represents the saved search.

Parameters
node
The node object representing the saved search node.

Returns
Array of ScriptNode objects

Example
var node = [Link]("Data Dictionary/Saved Searches/SilverSearch");
if (node){
var nodes = [Link](node);
[Link] = nodes;
[Link] = "Nodes found from saved search:";
}
else{
[Link] = "Saved search not found";
}

Parent topic: Search API [16]

savedSearch(noderef)

savedSearch(noderef) this method returns an array of ScriptNode objects that were found by executing the Saved Search referenced by the
supplied noderef string.

Parameters

noderef
The noderef string representing the saved search node.

Returns

Array of ScriptNode objects

Example
var node = [Link]("Data Dictionary/Saved Searches/GoldSearch");
if (node){

var nodeRef = [Link];


var nodeRefString = [Link]();

if ([Link](nodeRefString)){
var nodes = [Link](nodeRefString);
[Link] = nodes;
[Link] = "Nodes found from saved search:";
}
else{
[Link] = "nodeRefString not valid!";
}
}
else{
[Link] = "Saved search not found";
}

selectNodes
The selectNodes methods perform an XPath search and return a list of found nodes.

This method uses the underlying Node Service to perform a search. While this method provides full support for XPath syntax by using Jaxen,
use of the Node Service means that searches might be less performant, especially for queries such as unconstrained full­text searches. For
searches of such a nature it might be better to use xpathSearch(), which provides index­based searching at the cost of a more limited XPath
syntax.

CAUTION:

The following operators should be avoided or used with caution as they can potentially consume considerable resources:

selectNodes with //
selectNodes with /*
selectNodes with like

In general, avoid using selectNodes() unless you are looking for a specific path.

It is generally preferable to use a query language that searches against an index. This avoids potential excessive consumption of resources.

Comparison between searching with the Node Service and using index­based searching, plus further information on supported syntax can be
found in the developer Wiki [162].

Parent topic: Search API [16]

selectNodes(search)

selectNodes(search)

This method performs an XPath search on the default store, workspace://SpacesStore.

Parameters

search

The search string.

Returns

Returns an array of ScriptNode objects representing the search results.

selectNodes(store, search)

selectNodes(store, search)

This method performs an XPath search on the specified store.

Parameters

store

The store to search.

search

The search string.

Returns
Returns an array of ScriptNode objects representing the search results.

Example
var searchString = "//*"; // XPath search string
var store = "workspace://SpacesStore";

var nodes = [Link](store, searchString);

The following JavaScript snippet shows a typical search query:


// call in JS
[Link] = [Link]("/app:company_home/app:dictionary/*[like(@cm:name,'*templates')]")

Given the following FTL template:

<#list nodes as node>


<p>${[Link]}</p>
</#list>

The result would be:


Email Templates

Presentation Templates

Space Templates

RSS Templates

Node Templates

tagSearch
tagSearch(store, tag) performs a search on a given tag in a given store.

The default store (SpacesStore) is used if null value is supplied.

Parameters
store
The store in which to search. The default is workspace://SpacesStore if null is provided for this parameter.
tag
The tag to search for. Any node with this tag will be returned as part of an array of nodes.

Returns
Returns an array of ScriptNode objects that represent the nodes within the store that have the given tag applied.

Examples
var store = "workspace://SpacesStore";
var tag = "mining";
var nodes = [Link](store, tag);

Returns nodes that have the tag "mining" applied to them.

Parent topic: Search API [16]

xpathSearch
xpathSearch(xpath) performs an XPath search.

This method executes a search using a Lucene­based indexed query. The support for XPath is restricted but optimized. Being index­based,
this method can offer better performance than Node Service based methods such as selectNodes(), for searches such as unconstrained full­
text searches across large numbers of nodes.

Comparison between searching with the Node Service and using index­based searching, plus further information on supported syntax can be
found in the developer Wiki [162].

Parameters
xpath
The XPath search string

Returns
Returns an array of ScriptNode objects that were found by the Alfresco repository XPath search.
Example
var query = "//";
var nodes = [Link](query);

Parent topic: Search API [16]

xpathSearch(store, xpath)

xpathSearch(store, xpath)

This method performs an XPath search in a given store.

Parameters

store
The given store
xpath
The XPath string

Returns

Returns an array of ScriptNode objects that were found by the Alfresco repository XPath search in the given store.

Example
var query = "//";
var store = "archive://SpacesStore";
var nodes = [Link](store, query);

Session API
A root level session object is provided to access the servelt web session.

Properties
id
Gets the session ID.

getValue [163]object getValue(string name) returns an attribute value from the session.
setValue [164]void setValue(string name, object value) add or set an attribute for the session.
removeValue [165]void removeValue(string name) remove an attribute from the session.

Parent topic: Scripting API [3]

getValue
object getValue(string name) returns an attribute value from the session.

Parameters
String name
The name of the servelt web session attribute to return a value for.

Returns
An object representing the value of the attribute.

Parent topic: Session API [17]

setValue
void setValue(string name, object value) add or set an attribute for the session.

Parameters
String name
The name of the servlet web session attribute to add or set a value for.
object value
The value of the attribute to set or add to the session object.

Returns
void

Parent topic: Session API [17]

removeValue
void removeValue(string name) remove an attribute from the session.

Parameters
String name
The name of the servlet web session attribute to remove from the session object.

Returns
void

Parent topic: Session API [17]

SessionTicket API
A root level sessionticket object is provided to access the current logged in user session ticket as a string value.

Properties
ticket
Gets the current authentication ticket.

Parent topic: Scripting API [3]

Utility methods
A root level utils object is provided as a library of helper methods that are missing from generic JavaScript.

createPaging [166] The createPaging methods are used to build a ScriptPagingDetails object from the parameters supplied.
disableRules [167]disableRules disables rule execution for the current thread.
displayPath [168]displayPath(node) returns the cm:name display path for a node with minimum performance overhead.
enableRules [169]enableRules enables rule execution for the current thread.
fromISO8601 [170]fromISO8601(string) parses a date from an ISO8601 formatted string.
getLocale [171]getLocale returns the locale string for the current thread.
getNodeFromString [172]getNodeFromString(noderef) returns a ScriptNode object representing the supplied NodeRef string. The node is not
confirmed to exist in the repository.
longQName [173]longQName(string) returns the long version of a short prefixed QName.
moduleInstalled [174]moduleInstalled(moduleName) checks if a module is installed.
pad [175]pad(string, length) pads a string with leading zeros to the specified length.
setLocale [176]setLocale sets the locale for the current thread.
setServiceRegistry [177]setServiceRegistry(services) sets the service registry.
setNodeService [178]setNodeService(nodeService) sets the node service.
shortQName [179]shortQName(string) returns the short, or prefix, version of a long QName.
toBoolean [180]toBoolean(string) returns a Boolean object from a string value.
toISO8601(Date) [181]toISO8601(Date) formats a date to an ISO8601 formatted string.
toISO8601(long) [182]toISO8601(long) formats a time in milliseconds to an ISO8601 formatted string.

Parent topic: Scripting API [3]

createPaging
The createPaging methods are used to build a ScriptPagingDetails object from the parameters supplied.
Parent topic: Utility methods [19]

createPaging(maxItems, skipCount)
Builds a ScriptPagingDetails object from the supplied parameters.

Parameters
maxItems
An integer value which sets the maximum number of results to return.
skipCount
The number of results to skip.

Returns

Returns a ScriptPagingDetails object.

createPaging(maxItems, skipCount, queryExecutionId)

Builds a ScriptPagingDetails object from the supplied parameters.

Parameters

maxItems
An integer value which sets the maximum number of results to return.
skipCount
The number of results to skip.
queryExecutionId
Reserved for future use.

Returns

Returns a ScriptPagingDetails object.

createPaging(args)

Returns a ScriptPagingDetails object built from the supplied Args object. The Args object contains a map of parameters which must use their
standard names, such as maxItems, and skipCount.

Parameters

args
A map containing the parameters (using their standard names) and their corresponding values.

Returns
Returns a ScriptPagingDetails object.

disableRules
disableRulesdisables rule execution for the current thread.
Parent topic: Utility methods [19]

displayPath
displayPath(node) returns the cm:name display path for a node with minimum performance overhead.

Parameters
node
The script node.

Returns
Returns a cm:name based human readable display path for the give node.

Parent topic: Utility methods [19]

enableRules
enableRules enables rule execution for the current thread.
Parent topic: Utility methods [19]

fromISO8601
fromISO8601(string) parses a date from an ISO8601 formatted string.

Parameters
isoDateString
An ISO8601 formatted string to convert to a datetime object.

Returns
A date object.

Example
var date = new Date();
var timeInMillisecs = [Link]();
var ISODate = utils.toISO8601(timeInMillisecs);
var origDate = utils.fromISO8601(ISODate);

The preceding code snippet would result in the ISO8601 formatted string 2011‐11‐28T17:06:51.477Z being converted to the datetime object Nov
28, 2011 5:06:51 PM.

Parent topic: Utility methods [19]

getLocale
getLocale returns the locale string for the current thread.

Returns
Returns the locale string for the current thread.

Example
var localeString = [Link]();

The preceding code snippet would return a locale string such as en_US.

Parent topic: Utility methods [19]

getNodeFromString
getNodeFromString(noderef) returns a ScriptNode object representing the supplied NodeRef string. The node is not confirmed to exist in the
repository.

Parameters
noderef
The noderef string

Returns
Returns a ScriptNode object corresponding to the node referenced by the supplied NodeRef string.

Parent topic: Utility methods [19]

longQName
longQName(string) returns the long version of a short prefixed QName.

Parameters
string

Returns
Returns a string of the long version of a QName.

Example
var longQName = [Link]("cm:content");

The preceding code snippet would return longQName as {[Link]

Parent topic: Utility methods [19]

moduleInstalled
moduleInstalled(moduleName) checks if a module is installed.

Parameters
moduleName
A string representing the module name, for example [Link].

Returns
True if the specified module is installed.

Example
var result = false;
result = [Link]("[Link]");
[Link] = result;

The preceding code snippet would return result as true if the module was installed.

Parent topic: Utility methods [19]

pad
pad(string, length) pads a string with leading zeros to the specified length.

Parameters
string
The string to pad with leading '0' characters.
length
The length of the padded string.

Returns
Returns the new string.

Parent topic: Utility methods [19]

setLocale
setLocale sets the locale for the current thread.

Parameters
localeString
A locale string in ISO format, ISOLanguageCode_ISOCountryCode, for example en_US.

Example
[Link]("en_US");

The preceding code snippet would set the locale for the current thread to en_US.

Parent topic: Utility methods [19]

setServiceRegistry
setServiceRegistry(services) sets the service registry.

Parameters
services
The Service Registry.

Returns
void

Parent topic: Utility methods [19]

setNodeService
setNodeService(nodeService) sets the node service.

Parameters
nodeService
The Node Service to set.

Returns
void

Parent topic: Utility methods [19]

shortQName
shortQName(string) returns the short, or prefix, version of a long QName.

Parameters
string

Returns
Returns a string of the prefix version of a QName.

Example
var shortQName = [Link]("{[Link]

The preceding code snippet would return shortQName as cm:content.

Parent topic: Utility methods [19]

toBoolean
toBoolean(string) returns a Boolean object from a string value.

Parameters
booleanString
A boolean string, true or false.
Returns
Boolean value

Example
var booleanString = "true";

[Link] = [Link](booleanString);

The preceding code snippet would return a boolean value for result of true.

Parent topic: Utility methods [19]

toISO8601(Date)
toISO8601(Date) formats a date to an ISO8601 formatted string.

Parameters
Date
Date object to convert.

Returns
The date converted to an ISO8601 formatted string.

Example
var date = new Date();
var ISODate = utils.toISO8601(date);

The preceding code snippet would result in the datetime Nov 28, 2011 4:50:16 PM being converted to 2011‐11‐28T16:43:57.039Z.

Parent topic: Utility methods [19]

toISO8601(long)
toISO8601(long) formats a time in milliseconds to an ISO8601 formatted string.

Parameters
timeInMillis
A Long representing the time in millseconds to convert.

Returns
The time as an ISO8601 formatted string.

Example
var date = new Date();
var timeInMillisecs = [Link]();
var ISODate = utils.toISO8601(timeInMillisecs);

The preceding code snippet would convert the time in milliseconds 1,322,499,360,718 to the ISO8601 date time string 2011‐11‐28T16:56:00.718Z.

Parent topic: Utility methods [19]

Services API
The Alfresco JavaScript Services API provides an interface to core Alfresco services that can be accessed from web scripts.

The JavaScript Services API provides an interface from web scripts to a number of core Alfresco services including:

Activities service
Authority service
Rendition service
Site service
Tagging service
Thumbnail service
Workflow service

Each of these services APIs is described in the following sections.

Activities service [183] Activities refer to updates to content within a site, including uploaded files, blogs, discussions, calendars, and the
team wiki. The methods available for the Activities service are grouped into the Post activity and Feed controls object types.
Authority service [184] Authority is a general term to describe a group, user, or role. The authority service provides the following methods
to retrieve groups. The authority service makes the groups root object available.
Rendition service [185] A rendition is an alternative representation of a content node. Renditions are derived from their source nodes and
are usually updated automatically when their source node is updated.
Site service [186] A site is a collaborative area for a unit of work or a project. Sites are created in Share, and manipulated in various ways
directly using the UI or through web scripts or the REST API.
Tagging service [187] A tag is a non­hierarchical keyword or term assigned to a piece of information. The root object used to access these
services is taggingService.
Thumbnail service [188] A thumbnail is a transformation of content into a specified destination MIME type. This is most commonly an
image of a particular size, but can also be other things, for example, a Flash rendition. The Thumbnail service transforms and maintains
this thumbnail.
Workflow service [189] The Workflow JavaScript API lets you access Alfresco advanced workflows from within JavaScript.

Parent topic: JavaScript API [6]

Activities service
Activities refer to updates to content within a site, including uploaded files, blogs, discussions, calendars, and the team wiki. The methods
available for the Activities service are grouped into the Post activity and Feed controls object types.

getFeedControls [190]getFeedControls() gets feed control objects for the current user.
postActivity [191] The postActivity methods enable the posting of activities.
setFeedControl [192]setFeedControl(siteId, appToolId) sets the feed control for a site, an appTool, or a site/appTool combination for the
current user.
unsetFeedControl [193]unsetFeedControl(siteId,appTool) unsets the feed control for a site, an appTool, or a site/appTool combination for
the current user.

Parent topic: Services API [4]

getFeedControls
getFeedControls() gets feed control objects for the current user.

Returns
Returns an array of FeedControl objects.

Example
The following code snippet would return a list of feed controls for the current user:

[Link] = [Link]();

The following FreeMarker code could then be used to enumerate these objects:

<#list feedControls as fc>


<p>${[Link]}</p>
<p>${[Link]}</p>
</#list>

Parent topic: Activities service [183]

postActivity
The postActivity methods enable the posting of activities.
Parent topic: Activities service [183]

postActivity(activityType, siteId, appTool, jsonActivityData)


postActivity(activityType, siteId, appTool, jsonActivityData) posts a custom activity type.

Parameters
activityType
Required. Activity type name specified in package format, for example [Link]‐created.
siteId
Required parameter to get site members and to apply feed controls.
appTool
Optional parameter. The application id or component id generating the activity, for example calendarComponent. If set, then feed controls
can be applied.
jsonActivityData
Required. The activity data, which can be accessed by the activity templates.

Returns

void

Example
[Link]("[Link]‐created", "mysite1", "calendarComponent", '{ "item1" : 123 }');

postActivity(activityType, siteId, appTool, nodeRef)

this method posts a predefined activity type and looks up activity data asynchronously
postActivity(activityType, siteId, appTool, nodeRef)
including name, displayPath, typeQName, firstName (of posting user), lastName (of posting user).

Parameters

activityType
Required. Activity type name specified in package format, for example [Link]‐created.
siteId
Required parameter to get site members and to apply feed controls.
appTool
Optional parameter. The application id or component id generating the activity, for example calendarComponent. If set, then feed controls
can be applied.
nodeRef
Required. This allows the activity service to look up some generic data for the node.

postActivity(activityType, siteId, appTool, nodeRef, beforeName)

postActivity(activityType, siteId, appTool, nodeRef, beforeName) this method posts a predefined activity type, for example, for checked out
nodeRef or renamed nodeRef

Parameters

activityType
Required. Activity type name specified in package format, for example [Link]‐created.
siteId
Required parameter to get site members and to apply feed controls.
appTool
Optional parameter. The application id or component id generating the activity, for example calendarComponent. If set, then feed controls
can be applied.
nodeRef
Required. This allows the activity service to look up some generic data for the node.
beforeName
The name of the node prior to the name change.

postActivity(activityType,siteId,appTool,nodeRef,name,typeQName,parentNodeRef)

postActivity(activityType,siteId,appTool,nodeRef,name,typeQName,parentNodeRef) this method posts a predefined activity, for example, for the
deleted nodeRef.

Parameters

activityType
Required. Activity type name specified in package format, for example [Link]‐created.
siteId
Required parameter to get site members and to apply feed controls.
appTool
Optional parameter. The application id or component id generating the activity, for example calendarComponent. If set, then feed controls
can be applied.
nodeRef
Required. This allows the activity service to look up some generic data for the node.
name
Optional. The name of node.
typeQName
Optional. The type of node.
parentNodeRef
Optional. Used to look up path/displayPath

setFeedControl
setFeedControl(siteId, appToolId) sets the feed control for a site, an appTool, or a site/appTool combination for the current user.

Parameters
siteId
A string representing the short name of the site. Optional if appToolId is supplied.
appToolId
A string representing the application or component name. Optional if siteId is supplied.

Returns
void

Parent topic: Activities service [183]

unsetFeedControl
unsetFeedControl(siteId,appTool) unsets the feed control for a site, an appTool, or a site/appTool combination for the current user.

Parameters
siteId
A string representing the short name of the site. Optional if appToolId is supplied.
appToolId
A string representing the application or component name. Optional if siteId is supplied.

Parent topic: Activities service [183]

Authority service
Authority is a general term to describe a group, user, or role. The authority service provides the following methods to retrieve groups. The
authority service makes the groups root object available.

createRootGroup [194]createRootGroup(shortName,displayName) creates a new root group in the default application zone.
getAllRootGroups [195] The getAllRootGroups() methods return a list of groups found across all zones.
getAllRootGroupsInZone [196] The getAllRootGroupsInZone(zone) methods return a list of groups in the specified zone.
getGroup [197]getGroup(shortName) gets a group given its short name.
getGroupForFullAuthorityName [198]getGroupForFullAuthorityName(fullName) gets a group given its full authority name.
getGroups [199] The getGroups() methods return groups across all zones.
getGroupsInZone [200]getGroupsInZone(...) returns an array of ScriptGroup objects representing groups found in the specified zone.
getUser [201]getUser(username) gets a user given the user's user name.
searchGroups [202] The searchGroups() methods search for groups.
searchGroupsInZone [203] The searchGroupsInZone() methods search for groups in the specified zone.
searchRootGroups [204] The searchRootGroups() methods search for root groups across all zones.
searchRootGroupsInZone [205] The searchRootGroupsInZone() methods search for root groups in the specified zone.
searchUsers [206]searchUsers(nameFilter, paging, sortBy) returns an array of ScriptUsers that match the specified parameters.
ScriptGroup object [207] A ScriptGroup object represents an Alfresco group.
ScriptUser object [208] A ScriptUser object represents an Alfresco user.

Parent topic: Services API [4]

createRootGroup
createRootGroup(shortName,displayName) creates a new root group in the default application zone.

Parameters
shortName
A string representing the short name to assign the new group.
displayName
A string representing the display name to assign the new group.

Returns
Returns authority or null if it cannot be found.

Example
var shortName = "MY_GROUP";
var displayName = "MyGroup";

[Link] = [Link](shortName, displayName);

The preceding code snippet would create a new group with the following details:
fullName: GROUP_MY_GROUP

displayName: MyGroup

shortName: MY_GROUP

Parent topic: Authority service [184]

getAllRootGroups
The getAllRootGroups() methods return a list of groups found across all zones.
Parent topic: Authority service [184]

getAllRootGroups()

getAllRootGroups() this method returns a list groups found across all zones.

Returns

Returns an array of ScriptGroup objects, representing the groups found across all zones.

Example
[Link] = [Link]();

getAllRootGroups(maxItems, skipCount)

getAllRootGroups(maxItems, skipCount) this method returns a list groups found across all zones.

Parameters
maxItems
An integer representing the maximum number of items to return in the results.
skipCount
Integer representing the number of items to skip.

Returns

Returns an array of ScriptGroup objects, representing the groups found across all zones.

Example
[Link] = [Link](5, 0);

getAllRootGroups(paging)

getAllRootGroups(paging) this method returns a list groups found across all zones.

Parameters
paging
A ScriptPagingDetails object.

Returns
Returns an array of ScriptGroup objects, representing the groups found found across all zones.

Example
var paging = [Link](3, 0);

[Link] = [Link](paging);

getAllRootGroupsInZone
The getAllRootGroupsInZone(zone) methods return a list of groups in the specified zone.
Parent topic: Authority service [184]

getAllRootGroupsInZone(zone)

getAllRootGroupsInZone(zone) this method returns a list groups in the specified zone.

Parameters

zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.

Returns
Returns an array of ScriptGroup objects, representing the groups found in the specified zone.

Example
[Link] = [Link]("[Link]"); // [Link], [Link], [Link]

getAllRootGroupsInZone(zone, maxItems, skipCount)

getAllRootGroupsInZone(zone, maxItems, skipCount) this method returns a list groups in the specified zone.

Parameters

zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
maxItems
An integer representing the maximum number of items to return in the results.
skipCount
Integer representing the number of items to skip.

Returns

Returns an array of ScriptGroup objects, representing the groups found in the specified zone.

Example
[Link] = [Link]("[Link]", 5, 0);

getAllRootGroupsInZone(zone, paging, sortBy)

getAllRootGroupsInZone(zone, paging, sortBy) this method returns a list groups in the specified zone.

Parameters
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns
Returns an array of ScriptGroup objects, representing the groups found in the specified zone.

Example
var paging = [Link](3, 0);

[Link] = [Link]("[Link]", paging, "displayName");

getGroup
getGroup(shortName) gets a group given its short name.

Parameters
shortName
A string representing the short name of the group to return.

Returns
Returns a ScriptGroup object, or null if the group cannot be found.

Example
var shortName = "MY_GROUP";

[Link] = [Link](shortName);

Parent topic: Authority service [184]

getGroupForFullAuthorityName
getGroupForFullAuthorityName(fullName) gets a group given its full authority name.

Parameters
fullName
A string representing the full authority name of the group to return. This string must start with "GROUP_".

Returns
Returns a ScriptGroup object, or null if the group cannot be found.

Example
var fullName = "GROUP_MY_GROUP";

[Link] = [Link](fullName);

Parent topic: Authority service [184]

getGroups
The getGroups() methods return groups across all zones.
Parent topic: Authority service [184]

getGroups(filter, paging)

getGroups(filter, paging) this method returns groups across all zones.

Parameters
filter
Pattern to filter groups by. If the filter is null, an empty string or * all groups found will be returned. If the filter starts with * or contains a ?
character results returned could be inconsistent.
paging
A ScriptPagingDetails object.

Returns
An array of ScriptGroup objects.

Example
var filter = "Star";

// return all results, skip 0


var paging = [Link](‐1, 0);

[Link] = [Link](filter, paging);

getGroups(filter, paging, sortBy)

getGroups(filter, paging, sortBy) this method returns groups across all zones.

Parameters

filter
Pattern to filter groups by. If the filter is null, an empty string or * all groups found will be returned. If the filter starts with * or contains a ?
character results returned could be inconsistent.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

An array of ScriptGroup objects.

Example
var filter = "Star";

// return all results, skip 0


var paging = [Link](‐1, 0);

[Link] = [Link](filter, paging, "displayName");

The preceding code snippet would return results such as:


fullName: GROUP_Starlight_Title

displayName: Another group

shortName: Starlight_Title

fullName: GROUP_Admins

displayName: Starlight Admins

shortName: Admins

fullName: GROUP_FINANCE

displayName: Starlight Finance

shortName: FINANCE

fullName: GROUP_STARLIGHT

displayName: Starlight Group

shortName: STARLIGHT

getGroupsInZone
getGroupsInZone(...) returns an array of ScriptGroup objects representing groups found in the specified zone.
Parent topic: Authority service [184]

getGroupsInZone

getGroupsInZone(filter, zone, paging, sortBy) returns an array of ScriptGroup objects representing groups found in the specified zone.
Attention: Deprecated since 4.0.

Parameters
filter
Pattern to filter groups by. If the filter is null, an empty string or * all groups found will be returned. If the filter starts with * or contains a ?
character results returned could be inconsistent.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

An array of ScriptGroup objects from the specified zone.

Example
var filter = "Star";

// return all results, skip 0


var paging = [Link](‐1, 0);

[Link] = [Link](filter, "[Link]", paging, "displayName");

getGroupsInZone

getGroupsInZone(filter, zone, paging, sortBy, sortAsc) returns an array of ScriptGroup objects representing groups found in the specified zone.

Parameters
filter
Pattern to filter groups by. If the filter is null, an empty string or * all groups found will be returned. If the filter starts with * or contains a ?
character results returned could be inconsistent.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.
sortAsc
True to sort results in ascending order, false otherwise.

Returns

An array of ScriptGroup objects from the specified zone.

Example
var filter = "Star";

// return all results, skip 0


var paging = [Link](‐1, 0);

[Link] = [Link](filter, "[Link]", paging, "displayName", true);

getUser
getUser(username) gets a user given the user's user name.

Parameters
username
A string representing the user name of the user.

Returns
Returns a ScriptUser object, or null if the user cannot be found.

Example
var username = "[Link]";

[Link] = [Link](username);

The returned ScriptUser object can be passed to the following FreeMarker template code:

<p>authorityType: ${[Link]}</p>
<p>shortName: ${[Link]}</p>
<p>fullName: ${[Link]}</p>
<p>userName: ${[Link]}</p>
<p>displayName: ${[Link]}</p>
<p>personNodeRef: ${[Link]}</p>
<p>[Link]: ${[Link]}</p>
<p>[Link]: ${[Link]}</p>

The preceding FreeMarker code would display results similar to the following:

authorityType: USER

shortName: [Link]

fullName: [Link]

userName: [Link]

displayName: [Link]

personNodeRef: workspace://SpacesStore/4d7abb60‐d8ff‐4fcf‐956f‐93e53ebafed0

[Link]: 4d7abb60‐d8ff‐4fcf‐956f‐93e53ebafed0

[Link]: {[Link]

Parent topic: Authority service [184]

searchGroups
The searchGroups() methods search for groups.
Parent topic: Authority service [184]

searchGroups(shortNameFilter)

searchGroups(shortNameFilter) searches for groups based on short name filter string.

Parameters

shortNameFilter
A string to filter returned results on the short name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.

Returns

Returns an array of ScriptGroup objects that represents the groups matching the query.

searchGroups(shortNameFilter, paging, sortBy)

searchGroups(shortNameFilter, paging, sortBy) searches for groups based on a short name filter string.

Parameters
shortNameFilter
A string to filter returned results on the short name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns
Returns an array of ScriptGroup objects that represents the groups matching the query.

Example
// return maximum 3 results, skip 0
var paging = [Link](3, 0);

// property to sort by is displayName in this case


[Link] = [Link]("*", paging, "displayName");

searchGroupsInZone
The searchGroupsInZone() methods search for groups in the specified zone.
Parent topic: Authority service [184]

searchGroupsInZone(shortNameFilter, zone)

searchGroupsInZone(shortNameFilter, zone) this method searches for groups in the specified zone.

Parameters

shortNameFilter
A string to filter returned results on the short name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.

Returns
Returns a ScriptGroup array representing the groups matching the query.

searchGroupsInZone(shortNameFilter, zone, maxItems, skipCount)

searchGroupsInZone(shortNameFilter, zone, maxItems, skipCount) this method searches for groups in the specified zone.

Parameters

shortNameFilter
A string to filter returned results on the short name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
maxItems
An integer representing the maximum number of items to return in the results.
skipCount
Integer representing the number of items to skip.

Returns

Returns a ScriptGroup array representing the groups matching the query.

searchGroupsInZone(shortNameFilter, zone, paging, sortBy)

searchGroupsInZone(shortNameFilter, zone, paging, sortBy) this method searches for groups in the specified zone.

Parameters
shortNameFilter
A string to filter returned results on the short name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns
Returns a ScriptGroup array representing the groups matching the query.

Example
// return maximum 3 results, skip 0
var paging = [Link](3, 0);

// property to sort by is displayName in this case


[Link] = [Link]("*", "[Link]", paging, "displayName");

searchRootGroups
The searchRootGroups() methods search for root groups across all zones.
Parent topic: Authority service [184]

searchRootGroups(displayNamePattern)

searchRootGroups(displayNamePattern) searches for root groups based on the display name filter string.

Parameters

displayNamePattern
A string to filter returned results on the display name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.

Returns
Returns an array of ScriptGroup objects that represents the root groups matching the query.

searchRootGroups(displayNamePattern, paging, sortBy)

searchRootGroups(displayNamePattern, paging, sortBy) searches for root groups based on a display name pattern string.

Parameters

displayNamePattern
A string to filter returned results on the display name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

Returns an array of ScriptGroup objects that represents the root groups matching the query.

Example
// return maximum 3 results, skip 0
var paging = [Link](3, 0);

// property to sort by is displayName in this case


[Link] = [Link]("*", paging, "displayName");

searchRootGroupsInZone
The searchRootGroupsInZone() methods search for root groups in the specified zone.
Parent topic: Authority service [184]

searchRootGroupsInZone(displayNamePattern, zone)

searchRootGroupsInZone(displayNamePattern, zone) this method searches for root groups in the specified zone.
Parameters

displayNamePattern
A string to filter returned results on the display name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.

Returns

Returns a ScriptGroup array representing the groups matching the query.

searchRootGroupsInZone(displayNamePattern, zone, maxItems, skipCount)

searchRootGroupsInZone(displayNamePattern, zone, maxItems, skipCount) this method searches for root groups in the specified zone.

Parameters
displayNamePattern
A string to filter returned results on the display name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
maxItems
An integer representing the maximum number of items to return in the results.
skipCount
Integer representing the number of items to skip.

Returns

Returns a ScriptGroup array representing the root groups matching the query.

searchRootGroupsInZone(displayNamePattern, zone, paging, sortBy)

searchRootGroupsInZone(displayNamePattern, zone, paging, sortBy) this method searches for root groups in the specified zone.

Parameters

displayNamePattern
A string to filter returned results on the display name string. Wildcards such as "*" and "?" can be used. When empty string is used, all
results are returned without filtering.
zone
The zone in which to search. This could include application zones such as [Link], [Link], or [Link] or authorization
zones such as [Link] or [Link].<ID>.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

Returns a ScriptGroup array representing the root groups matching the query.

Example
// return maximum 3 results, skip 0
var paging = [Link](3, 0);

// property to sort by is displayName in this case


[Link] = [Link]("*", "[Link]", paging, "displayName");

searchUsers
searchUsers(nameFilter, paging, sortBy) returns an array of ScriptUsers that match the specified parameters.

Parameters
nameFilter
String to allow a partial match of the name. The user name, first name, and last name will all be checked to see if they start with the filter
string. If empty then the string will match all users.
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns
Returns an array of ScriptUser objects that represents the users matching the query.

Example
var filterName = "A";
var paging = [Link](‐1, 0);
var sortBy = "userName";

[Link] = [Link](filterName, paging, sortBy);

The return results could be displayed using the following FreeMarker template code snippet:

<#list scriptUsers as su>

<p>firstName: ${[Link]}</p>

<p>lastName: ${[Link]}</p>

<p>userName: ${[Link]}</p>

<hr/>
</#list>

The preceding code snippet would return results similar to the following:

firstName: Alice

lastName: Beecher

userName: abeecher

firstName: Administrator

lastName:

userName: admin

firstName: Tony

lastName: Tortilla

userName: Archvile

firstName: Peter

lastName: Andrews

userName: petethepiper

Parent topic: Authority service [184]

ScriptGroup object
A ScriptGroup object represents an Alfresco group.

Properties
authorityType
Get or set the authority type
allGroups
Gets all descendant subgroups
allUsers
Gets the users contained within this group and its subgroups
childUsers
Gets child users of this group
displayName
Get or set the display name for this group (requires administrator permission)
fullName
Get or set the full name of the group
shortName
Get or set the short name of the group

addAuthority [209]addAuthority(fullAuthorityName) adds an existing authority as a child of this group.


createGroup [210]createGroup(shortName, displayName) creates a new group as a child of this group.
deleteGroup [211]deleteGroup() deletes this group.
getAllGroups [212]getAllGroups() returns all descendant groups of this group.
getAllParentGroups [213] The getAllParentGroups() methods return all parent groups of this group.
getAllUsers [214]getAllUsers() returns all users contained in this group.
getChildAuthorities [215] The getChildAuthorities(...) methods return the child authorities (users and groups) of this group.
getChildGroups [216] The getChildGroups() methods return child groups of this group.
getChildUsers [217] The getChildUsers(...) methods get the child users of this group.
getGroupCount [218]getGroupCount() returns the number of child groups contained within this group.
getGroupNode [219]getGroupNode() returns a script node object wrapping this group.
getGroupNodeRef [220]getGroupNodeRef() returns the node reference of this group.
getParentGroups [221] The getParentGroups() methods return the immediate parent groups of this group.
getUserCount [222]getUserCount() returns the number of users within this group.
getZones [223]getZones() returns a set of zone names for this group. Zones provide a higher level way of organizing groups.
removeAuthority [224]removeAuthority(fullAuthorityName) removes a child authority from this group.
removeGroup [225]removeGroup(shortName) removes a specified subgroup from this group. It does not delete the subgroup or its members.
removeUser [226] The removeUser(shortName) removes a specified child user from this group. It does not delete the user.

Parent topic: Authority service [184]

addAuthority
addAuthority(fullAuthorityName) adds an existing authority as a child of this group.

Parameters
fullAuthorityName
A string representing the full name of the authority.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now add authority to this group

var fullName = "GROUP_MY_TEST_GROUP";


[Link](fullName);

Parent topic: ScriptGroup object [207]

createGroup
createGroup(shortName, displayName) creates a new group as a child of this group.

Parameters
shortName
A string representing the short name for the new group.
displayName
A string representing the display name for the new group.

Returns
Returns the new child group.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

// now create child group of this group

var shortName = "MY_SUB_GROUP";


var displayName = "MySubGroup";
[Link] = [Link](shortName, displayName);

Parent topic: ScriptGroup object [207]

deleteGroup
deleteGroup() deletes this group.

Parameters
None

Returns
void

Example
var shortName = "MY_TEST_GROUP";
var group = [Link](shortName);

// now delete this group

[Link]();

Parent topic: ScriptGroup object [207]

getAllGroups
getAllGroups() returns all descendant groups of this group.

Parameters
None

Returns
An array of ScriptGroup objects.

Example
var groups = [Link]();

Parent topic: ScriptGroup object [207]

getAllParentGroups
The getAllParentGroups() methods return all parent groups of this group.
Parent topic: ScriptGroup object [207]

getAllParentGroups()

getAllParentGroups() this method returns all parent groups of this group.

Parameters

None

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);
// now find all parent groups
[Link] = [Link]();

getAllParentGroups(maxItems, skipCount)

getAllParentGroups(maxItems, skipCount) this method returns all parent groups of this group.

Parameters
maxItems
An integer representing the maximum number of results to return. If set to ­1 all results will be returned.
skipCount
An integer representing the number of results to skip.

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_SUB_SUB_GROUP";
var group = [Link](shortName);

// now find all parent groups


var maxItems = ‐1;
var skipCount = 0;
[Link] = [Link](maxItems, skipCount);

getAllParentGroups(paging, sortBy)

getAllParentGroups(paging, sortBy) this method returns all parent groups of this group.

Parameters
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_SUB_SUB_GROUP";
var group = [Link](shortName);

// now find immediate parent groups


var paging = [Link](‐1, 0);
var sortBy = "displayName";
[Link] = [Link](paging, sortBy);

getAllUsers
getAllUsers() returns all users contained in this group.

Parameters
None

Returns
An array of ScriptUser objects representing the users contained in this group.

Example
var users = [Link]();
Parent topic: ScriptGroup object [207]

getChildAuthorities
The getChildAuthorities(...) methods return the child authorities (users and groups) of this group.
Parent topic: ScriptGroup object [207]

getChildAuthorities

getChildAuthorities() this method returns the child authorities (users and groups) of this group.

Parameters

None

Returns

An array of Authority objects.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

[Link] = [Link]();

The following FreeMarker code could be used to display the results from the preceding JavaScript code snippet:

<#list childAuthorities as ca>

<p>fullName: ${[Link]}</p>
<p>displayName: ${[Link]}</p>
<p>shortName: ${[Link]}</p>
<p>authorityType: ${[Link]}</p>

<hr/>
</#list>

The preceding code would display results such as the following:


fullName: abeecher

displayName: abeecher

shortName: abeecher

authorityType: USER

fullName: GROUP_ANOTHER_STARLIGHT_GROUP

displayName: Another example group

shortName: ANOTHER_STARLIGHT_GROUP

authorityType: GROUP

fullName: mjackson

displayName: mjackson

shortName: mjackson

authorityType: USER

fullName: GROUP_MY_SUB_GROUP

displayName: MySubGroup

shortName: MY_SUB_GROUP

authorityType: GROUP

fullName: GROUP_FINANCE

displayName: Starlight Finance

shortName: FINANCE

authorityType: GROUP
getChildAuthorities

getChildAuthorities(paging, sortBy) this method returns the child authorities (users and groups) of this group.

Parameters
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

An array of Authority objects.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

// now find child authorities


var paging = [Link](‐1, 0);
var sortBy = "displayName";
[Link] = [Link](paging, sortBy);

The following FreeMarker code could be used to display the results from the preceding JavaScript code snippet:

<#list childAuthorities as ca>

<p>fullName: ${[Link]}</p>
<p>displayName: ${[Link]}</p>
<p>shortName: ${[Link]}</p>
<p>authorityType: ${[Link]}</p>

<hr/>
</#list>

The preceding code would display results such as the following:


fullName: abeecher

displayName: abeecher

shortName: abeecher

authorityType: USER

fullName: GROUP_ANOTHER_STARLIGHT_GROUP

displayName: Another example group

shortName: ANOTHER_STARLIGHT_GROUP

authorityType: GROUP

fullName: mjackson

displayName: mjackson

shortName: mjackson

authorityType: USER

fullName: GROUP_MY_SUB_GROUP

displayName: MySubGroup

shortName: MY_SUB_GROUP

authorityType: GROUP

fullName: GROUP_FINANCE

displayName: Starlight Finance

shortName: FINANCE

authorityType: GROUP

getChildGroups
The getChildGroups() methods return child groups of this group.
Parent topic: ScriptGroup object [207]

getChildGroups()

getChildGroups() this method returns child groups of this group.

Parameters
None

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

// now find child groups


[Link] = [Link]();

getChildGroups(maxItems, skipCount)

getChildGroups(maxItems, skipCount) this method returns child groups of this group.

Parameters
maxItems
An integer representing the maximum number of results to return. If set to ­1 all results will be returned.
skipCount
An integer representing the number of results to skip.

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

// now find child users


var maxItems = ‐1; // return all results
var skipCount = 0; // skip 0 results
[Link] = [Link](maxItems, skipCount);

getChildGroups(paging, sortBy)

getChildGroups(paging, sortBy) this method returns the child groups of this group.

Parameters

paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

// now find child users


var paging = [Link](‐1, 0);
var sortBy = "displayName";
[Link] = [Link](paging, sortBy);
getChildUsers
The getChildUsers(...) methods get the child users of this group.
Parent topic: ScriptGroup object [207]

getChildUsers

getChildUsers() this method gets the child users of this group.

Parameters

None

Returns

Returns an array of ScriptUser objects.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now find child users


[Link] = [Link]();

getChildUsers

getChildUsers(paging, sortBy) this method gets the child users of this group.

Parameters

paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example userName.

Returns
Returns an array of ScriptUser objects.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now find child users


var paging = [Link](‐1, 0);
var sortBy = "userName";
[Link] = [Link](paging, sortBy);

getGroupCount
getGroupCount() returns the number of child groups contained within this group.

Parameters
None

Returns
Returns an integer representing the number of child groups contained within this group.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now find group count


[Link] = [Link]();
Parent topic: ScriptGroup object [207]

getGroupNode
getGroupNode() returns a script node object wrapping this group.

Parameters
None

Returns
Returns a script node object wrapping this group.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now find group node


[Link] = [Link]();

Parent topic: ScriptGroup object [207]

getGroupNodeRef
getGroupNodeRef() returns the node reference of this group.

Parameters
None

Returns
Returns a script node object wrapping this group.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now get group node ref


[Link] = [Link]();

Parent topic: ScriptGroup object [207]

getParentGroups
The getParentGroups() methods return the immediate parent groups of this group.
Parent topic: ScriptGroup object [207]

getParentGroups()

getParentGroups() this method returns immediate parent groups of this group.

Parameters

None

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_SUB_SUB_GROUP";
var group = [Link](shortName);

// now find immediate parent groups


[Link] = [Link]();

getParentGroups(maxItems, skipCount)

getParentGroups(maxItems, skipCount) this method returns immediate parent groups of this group.

Parameters
maxItems
An integer representing the maximum number of results to return. If set to ­1 all results will be returned.
skipCount
An integer representing the number of results to skip.

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_SUB_SUB_GROUP";
var group = [Link](shortName);

// now find immediate parent groups


var maxItems = ‐1;
var skipCount = 0;
[Link] = [Link](maxItems, skipCount);

getParentGroups(paging, sortBy)

getParentGroups(paging, sortBy) this method returns the immediate parent groups of this group.

Parameters
paging
A ScriptPagingDetails object.
sortBy
The property by which to sort the results, for example displayName.

Returns

An array of ScriptGroup objects.

Example
var shortName = "MY_SUB_SUB_GROUP";
var group = [Link](shortName);

// now find immediate parent groups


var paging = [Link](‐1, 0);
var sortBy = "displayName";
[Link] = [Link](paging, sortBy);

getUserCount
getUserCount() returns the number of users within this group.

Parameters
None

Returns
Returns an integer representing the number of users contained within this group.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now find group count


[Link] = [Link]();

Parent topic: ScriptGroup object [207]

getZones
getZones() returns a set of zone names for this group. Zones provide a higher level way of organizing groups.

Parameters
None

Returns
Returns a set of strings representing the zones of this group.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now return zones


[Link] = [Link]();

Parent topic: ScriptGroup object [207]

removeAuthority
removeAuthority(fullAuthorityName) removes a child authority from this group.

Parameters
fullAuthorityName
A string representing the full name of the authority.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now remove authority from this group

var fullName = "GROUP_MY_TEST_GROUP";


[Link](fullName);

Parent topic: ScriptGroup object [207]

removeGroup
removeGroup(shortName) removes a specified subgroup from this group. It does not delete the subgroup or its members.

Parameters
shortName
A string representing the short name of the sub group to remove from the containing group.

Example
var shortName = "MY_GROUP";
var group = [Link](shortName);

// now remove child group of this group

var shortName = "MY_SUB_GROUP";


[Link](shortName);
Parent topic: ScriptGroup object [207]

removeUser
The removeUser(shortName) removes a specified child user from this group. It does not delete the user.

Parameters
shortName
The short name of the user to remove.

Example
var shortName = "MY_SUB_GROUP";
var group = [Link](shortName);

// now remove child user from this group

var shortName = "[Link]";


[Link](shortName);

Parent topic: ScriptGroup object [207]

ScriptUser object
A ScriptUser object represents an Alfresco user.

Properties
authorityType
Gets or sets the authority type (user, group, role)
displayName
Gets or sets the display name of the user
fullName
Gets or sets the full name of the user
person
Gets the ScriptNode object representing the person
personNodeRef
Gets the nodeRef for the user
shortName
Gets or sets the short name of the user
userName
Gets the user name of the user

getPerson [227]getPerson() returns a script node wrapping the person.


getZones [228]getZones() returns all the zones of this user.

Parent topic: Authority service [184]

getPerson
getPerson() returns a script node wrapping the person.

Parameters
None

Returns
Returns a script node wrapping the person.

Example
var username = "[Link]";

var scriptUser = [Link](username);

var person = [Link]();


Parent topic: ScriptUser object [208]

getZones
getZones() returns all the zones of this user.

Parameters
None

Returns
Returns a set of strings representing all the zones of this user.

Example
var username = "[Link]";

var scriptUser = [Link](username);

var zones = [Link]();

Parent topic: ScriptUser object [208]

Rendition service
A rendition is an alternative representation of a content node. Renditions are derived from their source nodes and are usually updated
automatically when their source node is updated.

Thumbnails are a special case of renditions which are still available through the Thumbnail Service. Other examples include content that has
been transformed into other formats (MIME types), images that have been processed in some way or content which incorporates property
values from the source node. Rendition Services are grouped into the following object types:

Rendition Service
Rendition Definition

createRenditionDefinition [229]createRenditionDefinition(renditionName, renderingEngineName) creates a new rendition definition with the


specified rendition name which uses the specified rendering engine.
getRenditionByName [230]getRenditionByName(node, renditionName) retrieves existing renditions for a node by rendition name.
getRenditions [231] The getRenditions methods retrieve existing renditions for a node.
render [232] The render(...) methods generate a rendition from a specified node.
Rendition definition [233] The ScriptRenditionDefinition extends from ScriptAction and fully specifies a type of rendition.
getrenderingEngineName and getRenditionName are extensions to the existing JavaScript API for script actions.

Parent topic: Services API [4]

createRenditionDefinition
createRenditionDefinition(renditionName, renderingEngineName) creates a new rendition definition with the specified rendition name which uses
the specified rendering engine.

Parameters
renditionName
The rendition definition name. A unique identifier used to specify the created definition.
renderingEngineName
The rendering engine name. The name of the rendering engine associated with this definition.

Returns
Returns the newly created ScriptRenditionDefinition object.
Parent topic: Rendition service [185]

getRenditionByName
getRenditionByName(node, renditionName) retrieves existing renditions for a node by rendition name.
Parameters
node
The source nodes for the renditions.
renditionName
The name used to identify a rendition. For example cm:doclib or {[Link]

Returns
Returns a ScriptNode which represents the parent association for the rendition or null if there is no such rendition.

Parent topic: Rendition service [185]

getRenditions
The getRenditions methods retrieve existing renditions for a node.
Parent topic: Rendition service [185]

getRenditions(node)

getRenditions(node) this method gets renditions for the specified node.

Parameters

node
The node whose renditions are requested

Returns
Returns a ScriptNode array of all existing rendition objects for the specified node.

getRenditions(node, mimeTypePrefix)

getRenditions(node, mimeTypePrefix) this method gets renditions for the specified node.

Parameters

node
The node whose renditions are requested
mimeTypePrefix
A filter to restrict the renditions returned to those whose MIME­type starts with the prefix. This must not be null or an empty string.

Returns

Returns an array of ScriptNode objects representing all existing rendition objects for the specified node whose MIME­type starts with the given
filter string.

render
The render(...) methods generate a rendition from a specified node.
Parent topic: Rendition service [185]

render(sourceNode, scriptRenditionDef)

render(sourceNode, renditionDefQName) this method uses a rendition definition to produce a rendition from a specified node.

Parameters

sourceNode
The node for which a rendition should be created
scriptRenditionDef
The ScriptRenditionDefinition object to use to render the rendition.

Returns

Returns the new rendition object (a ScriptNode) object.


render

render(sourceNode, renditionDefQName) this method uses a saved rendition definition to produce a rendition from a specified node.

Parameters
sourceNode
The node for which a rendition should be created
renditionDefQName
The qname of the rendition definition to use for example cm:doclib or {[Link]

Returns

Returns the new rendition object (a ScriptNode) object.

Rendition definition
The ScriptRenditionDefinition extends from ScriptAction and fully specifies a type of rendition. getrenderingEngineName and getRenditionName are
extensions to the existing JavaScript API for script actions.

getRenderingEngineName [234]getRenderingEngineName() retrieves the name of the rendering engine used by the current rendition
definition.
getRenditionName [235]getRenditionName() retrieves the name of the current rendition definition.

Parent topic: Rendition service [185]

getRenderingEngineName
getRenderingEngineName() retrieves the name of the rendering engine used by the current rendition definition.

Returns
Returns the name of the rendering engine used by the current rendition definition.

Parent topic: Rendition definition [233]

getRenditionName
getRenditionName() retrieves the name of the current rendition definition.

Returns
Returns the name of this rendition definition in prefix:localName format.

Parent topic: Rendition definition [233]

Site service
A site is a collaborative area for a unit of work or a project. Sites are created in Share, and manipulated in various ways directly using the UI or
through web scripts or the REST API.

The methods available for the Site service are grouped into siteService and site object types.

Site service object [236] The siteService object provides methods to create sites, list sites in the repository, list roles that can be assigned
to members of a site, and get sites for given names.
Site object [237] The site object provides site related properties and methods.

Parent topic: Services API [4]

Site service object


The siteService object provides methods to create sites, list sites in the repository, list roles that can be assigned to members of a site, and get
sites for given names.

cleanSitePermissions [238]cleanSitePermissions() these methods clean permissions from a node.


createSite [239] The createSite(...) methods partially create a new site.
findSites [240]findSites(filter, sitePresetFilter, size) searches for and returns a list of sites. The returned list can be optionally filtered
by name and site preset. If no filters are specified then all the available sites are returned.
getSite [241]getSite(shortName) gets a site for a provided short name.
getSites [242]getSites(filter, sitePresetFilter, size) returns a list of sites. Retrieves all the sites available in the repository. The returned
list can optionally be filtered by name and site preset. If no filters are specified then all the available sites are returned.
hasCreateSitePermissions [243]hasCreateSitePermissions() returns true if the currently logged on user has permission to create a site.
hasSite [244]hasSite(String shortName) returns true if the specified site exists. Allows private site existence to be tested.
isSiteManager [245]isSiteManager(siteId) checks whether the currently authenticated user is a site manager or not, for the specified site.
listSiteRoles [246] The listSiteRoles() methods list all the roles that can be assigned to a member of a site.
listSites [247] The listSites methods list the sites that are available in the repository.
listUserSites [248] The listUserSites() methods list all the sites to which the specified user has an explicit membership.

Parent topic: Site service [186]

cleanSitePermissions
cleanSitePermissions() these methods clean permissions from a node.

When a node is moved or copied from one site to another, the node will retain associated permissions assigned in the source site. These
methods allow any permission from outside of the current site to be removed, so that only the permissions of the containing site will apply to
the specified node.

Parent topic: Site service object [236]

cleanSitePermissions(ScriptNode targetNode)

cleanSitePermissions(ScriptNode targetNode) cleans permissions from the node specified by the supplied ScriptNode object.

Parameters

targetNode
The target node on which to perform the clean operation.

Returns

void

Example
[Link](node);

cleanSitePermissions(NodeRef targetNode)

cleanSitePermissions(NodeRef targetNode) cleans permissions from the node specified by the supplied nodeRef.

Parameters
targetNode
The node reference of the target node on which to perform the clean operation.

Returns

void

Example
[Link](nodeRef);

createSite
The createSite(...) methods partially create a new site.
CAUTION:
These methods will only create a site at the repository level, and do not create a fully functional site. It should be considered for internal use
only at the moment. You need to create a site programmatically in the Share context, using the create‐site module. Further information can be
found at the address [Link] within your Alfresco installation.
Parent topic: Site service object [236]

createSite
createSite(sitePreset, shortName, title, description, visibility) creates a new site.
CAUTION:
This method only creates a site at the repository level, it does not create a fully functional site. It should be considered for internal use only at
the moment. You need to a site programmatically in the Share context, using the create‐site module. Further information can be found at the
address [Link] within your Alfresco installation.

Parameters
sitePreset
The site preset, for example site‐dashboard or custom­defined preset.
shortName
The unique site short name to identify the site
title
A title for the site
description
A description for the site
visibility
The visibility of the site, which is one of siteService.PUBLIC_SITE, siteService.MODERATED_SITE, siteService.PRIVATE_SITE.

Returns

Returns a Site object representing the created site with the specified parameters.

Example
var site = [Link]("site‐dashboard", "gamma‐site", "Gamma Site", "A site description", siteService.PUBLIC_SITE);

createSite

createSite(sitePreset, shortName, title, description, visibility, siteType) creates a new site.


CAUTION:
This method only creates a site at the repository level, it does not create a fully functional site. It should be considered for internal use only at
the moment. Youy need to create a site programmatically in the Share context, using the create‐site module. Further information can be found
at the address [Link] within your Alfresco installation.

Parameters

sitePreset
The site preset, for example site‐dashboard or custom­defined preset.
shortName
The unique site short name to identify the site
title
A title for the site
description
A description for the site
visibility
The visibility of the site, which is one of siteService.PUBLIC_SITE, siteService.MODERATED_SITE, siteService.PRIVATE_SITE.
siteType
QName of site type to create. By default this would be a collaboration site, st:site. It is possible to create other types of site, and these
can be selected here. This value must be a sub­type of st:site.

Returns

Returns a Site object representing the created site with the specified parameters.

Example
var site = [Link]("site‐dashboard", "gamma‐site", "Gamma Site", "A site description", siteService.PUBLIC_SITE, "st:site");

findSites
findSites(filter, sitePresetFilter, size) searches for and returns a list of sites. The returned list can be optionally filtered by name and site
preset. If no filters are specified then all the available sites are returned.

This method will find all sites available to the currently authenticated user based on the specified site filter, site preset filter and result set size.
The filter parameter will match any sites whose cm:name, cm:title, cm:description contain the specified string (ignoring case). Note that this
method uses Alfresco Full Text Search [249] to retrieve results and depending on SOLR configuration can only offer eventually consistent results.

Parameters
filter
An inclusion filter string for returned sites. Any supplied filter will be wrapped in asterisks, for example as in '*foo*', and used to match
sites whose cm:name, cm:title, or cm:description contains the filter string.
sitePresetFilter
Site preset filter name to match against.
size
The maximum number of results to return. The default, 0, returns all results.

Returns
Returns a list of Site objects. The list can be empty, but not null.

Example
The following code snippet will search for all sites that contain 'foo' in their name, title or description:
var sites = [Link]('foo', null, 0);

Parent topic: Site service object [236]

getSite
getSite(shortName) gets a site for a provided short name.

Parameters
shortName
The short name of the site

Returns
Return a site object, or returns null if the site does not exist.

Example
var site = [Link]("simple‐site");

if(site){

[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
}

Parent topic: Site service object [236]

getSites
getSites(filter, sitePresetFilter, size) returns a list of sites. Retrieves all the sites available in the repository. The returned list can optionally
be filtered by name and site preset. If no filters are specified then all the available sites are returned.

If filters start with a "*" character, a Solr­based search will be performed, rather than a database query. This can discover a wider range of
results, such as those sites that contain the search term, as opposed to those that start with the search term.

Within the implementation of this method, if the query does not contain a wildcard, then listSites() is invoked, else findSites() is used instead.

Note: When using Solr searches, rather than direct database queries, newly created sites might not be found until the underlying search
indexes are updated.

Parameters
filter
An inclusion filter string for returned sites. Only sites whose cm:name, cm:title, or cm:description start with the filter string will be returned.
sitePresetFilter
Site preset filter string.
size
The maximum number of results to return. The default, 0, returns all results.
Returns
Returns a list of Site objects. The list can be empty, but not null.

Example
The following code snippet will return all sites:

var sites = [Link](null, null, 0);

Parent topic: Site service object [236]

hasCreateSitePermissions
hasCreateSitePermissions() returns true if the currently logged on user has permission to create a site.

Returns
Returns a boolean. Returns true if the currently authenticated user has permission to create a site, false otherwise.

Example
var result = [Link]();

Parent topic: Site service object [236]

hasSite
hasSite(String shortName) returns true if the specified site exists. Allows private site existence to be tested.

Returns
Returns a boolean. Returns true if specified site exists, false otherwise.

Example
var result = [Link]();

Parent topic: Site service object [236]

isSiteManager
isSiteManager(siteId) checks whether the currently authenticated user is a site manager or not, for the specified site.

Parameters
siteId
The short name of the site to check.

Returns
Returns a boolean. True is returned if the currently authenticated user is a site manager, false otherwise.

Example
result = [Link]("simple‐site");

Parent topic: Site service object [236]

listSiteRoles
The listSiteRoles() methods list all the roles that can be assigned to a member of a site.
Parent topic: Site service object [236]

listSiteRoles

listSiteRoles() lists all the roles that can be assigned to a member of a site.

Returns
Returns an array containing strings representing the roles available to assign to a member of a site.

Example
var roles = [Link]();

The preceding code snippet would return a list of roles such as:
SiteManager

SiteCollaborator

SiteContributor

SiteConsumer

listSiteRoles(shortName)

listSiteRoles(shortName) lists all the roles that can be assigned to a member of a site, for a specific site.

Parameters

shortName
A string representing the short name of the site to list roles for.

Returns
Returns an array containing strings representing the roles available to assign to a member of a site.

Example
var roles = [Link]("test‐site");

The preceding code snippet would return a list of roles for the specified site, such as:
SiteManager

SiteCollaborator

SiteContributor

SiteConsumer

listSites
The listSites methods list the sites that are available in the repository.

List the available sites. This list can optionally be filtered by site name/title/description and/or site preset. This method uses a database query
rather than using Solr.

Note: Starting with Alfresco 4.0, the filter parameter will only match sites whose cm:name or cm:title or cm:description starts with the specified
string (ignoring case). The listing of sites whose cm:names (or titles or descriptions) contain the specified string is no longer supported. To
retrieve sites whose cm:names (or titles or descriptions) contain a substring, findSites(String, String, int) should be used instead.
Parent topic: Site service object [236]

listSites(nameFilter, sitePresetFilter)

listSites(nameFilter, sitePresetFilter) lists the sites that are available in the repository.

Parameters

nameFilter
String by which to filter the list of sites returned. Only sites whose cm:name or cm:title or cm:description start with the filter string will be
returned.
sitePresetFilter
The site preset filter (sites whose preset EQUALS sitePresetFilter).

Returns
A list of the sites filtered, as appropriate. If no filters are specified then all the available sites are returned.

listSites(nameFilter, sitePresetFilter, size)

listSites(nameFilter, sitePresetFilter, size) lists the sites that are available in the repository.

Parameters

nameFilter
String by which to filter the list of sites returned. Only sites whose cm:name or cm:title or cm:description starts with the filter string will be
returned.
sitePresetFilter
The site preset filter.
size
The maximum number of sites to return. By default this is set to 0, which returns all results.

Returns

A list of the sites filtered, as appropriate. If no filters are specified then all the available sites are returned.

Example

The following code snippet would return all sites without any filtering or restriction on number of results returned:
var sites = [Link](null, null, 0);

The following code snippet would return all dashboard sites whose name, title or description starts with the text "test" and restricts the number
of sites returned to 5:
var sites = [Link]("test", null, 5);

listUserSites
The listUserSites() methods list all the sites to which the specified user has an explicit membership.
Parent topic: Site service object [236]

listUserSites

listUserSites(userName) lists all the sites to which the specified user has an explicit membership.

Parameters

userName
The user name for the user whose site membership is to be listed.

Returns

Returns a list of the sites to which the specified user has an explicit membership.

Example
var sites = [Link]("admin");

listUserSites

listUserSites(userName, size) lists all the sites to which the specified user has an explicit membership.

Parameters

userName
The user name for the user whose site membership is to be listed.
size
An integer representing the number of results to return. The default is 0 which returns all results.
Returns

Returns a list of the sites to which the specified user has an explicit membership.

Example
var sites = [Link]("admin", 10);

Site object
The site object provides site related properties and methods.

Properties
description
The displayable description of the site.
isPublic
Whether the site is public or not (true or false).
node
The site node (null if there are none).
shortName
A read­only unique short name identifying the site.
siteGroup
The site group name.
sitePermissionGroups
A map of role name mapped to associated group name.
sitePreset
A read­only name of the site preset used to create the site.
title
The displayable title of the site.
visibility
The visibility of the site (PUBLIC_SITE, MODERATED_SITE, PRIVATE_SITE)

Example
var site = [Link]("simple‐site");

if(site){

[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
[Link] = [Link];
}

acquireContainer [250]acquireContainer(...) gets and, if missing, creates a new site container. The container is created in a new
read/write transaction.
createAndSaveContainer [251]createAndSaveContainer(containerId, containerType, description) indicates whether a user is a member of
the site.
createContainer [252] The createContainer methods create new site containers.
deleteSite [253]deleteSite() deletes a site.
getContainer [254]getContainer(componentId) gets (or creates) the container folder (node) folder for the specified component identifier with
the container type cm:folder.
getCustomProperties [255]getCustomProperties() gets a map of the custom properties of the site.
getCustomProperty [256]getCustomProperty(name) gets the value of a custom property (null if the custom property has not been set or does
not exist).
getInvitation [257]getInvitation(invitationId) gets an invitation to this web site.
getMembersRole [258]getMembersRole(authorityName) returns a user's role in this site.
getMembersRoleInfo [259]getMembersRoleInfo(authorityName) returns extended information about a user's role in this site.
hasContainer [260]hasContainer(componentId) determines if the container folder for the specified component exists; if true the container
folder exists.
inviteModerated [261]inviteModerated(inviteeComments, inviteeUserName, inviteeRole) creates a new moderated invitation to the specified
web site.
inviteNominated (new user) [262]inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRole, acceptUrl, rejectUrl)
creates a new nominated invitation to this web site for a new user who might not already be an Alfresco user.
inviteNominated (existing user) [263]inviteNominated(inviteeUserName, inviteeRole, acceptUrl, rejectUrl) creates a new nominated
invitation to this web site for an existing user.
isMember [264]isMember(authorityName) indicates whether a user is a member of the site.
isMemberOfGroup [265]isMemberOfGroup(authorityName) indicates whether a user belongs to a group that has access rights to the site.
listInvitations [266]listInvitations() lists the outstanding invitations for this web site.
listMembers [267]listMembers(nameFilter, roleFilter, size, collapseGroups) gets a map of members of the site filtered by user name
and/or user role.
removeMembership [268]removeMembership(authorityName) removes the specified user from a web project.
resetAllPermissions [269]resetAllPermissions(node) resets any permissions that have been set on the node, deleting all permissions and
setting the node to inherit permissions.
save [270]save() saves any outstanding updates to the site detail. Those changes will be lost if properties of the site change and the save
method is not called.
setMembership [271]setMembership(authorityName, role) sets the membership details for a user.
setPermissions [272]setPermissions(node, permissions) sets permissions for a node.

Parent topic: Site service [186]

acquireContainer
acquireContainer(...) gets and, if missing, creates a new site container. The container is created in a new read/write transaction.
Parent topic: Site object [237]

acquireContainer

acquireContainer(String componentId) gets and if missing creates a new site container. The container is created in a new read/write transaction.

Parameters

component ID
A string specifying the component ID.

Returns

A ScriptNode object representing the newly created container.

acquireContainer

acquireContainer(String componentId, String folderType) gets and if missing creates a new site container. The container is created in a new
read/write transaction.

Parameters

componentId
A string specifying the component ID.
folderType
The folder type to create.

Returns
A ScriptNode object representing the newly created container.

acquireContainer

acquireContainer(String componentId, String folderType, Object properties) gets and if missing creates a new site container. The container is
created in a new read/write transaction.

Parameters

componentId
A string specifying the component ID.
folderType
The folder type to create.
properties
The properties to set on the container.

Returns

A ScriptNode object representing the newly created container.

createAndSaveContainer
createAndSaveContainer(containerId, containerType, description) indicates whether a user is a member of the site.
Parameters
containerId
A string specifying the id for the container node.
containerType
A string specifying the type for the container node.
description
A string specifying a value for the cm:description property on the container node.

Returns
A ScriptNode object representing the newly created and saved container.

Parent topic: Site object [237]

createContainer
The createContainer methods create new site containers.
Parent topic: Site object [237]

createContainer

The createContainer(componentId) method creates a new site container of type cm:folder.

Parameters

componentId
The component identifier

createContainer

The createContainer(componentId, folderType) method creates a new site container of the given type (type of container of subtype of cm:folder).

Parameters

componentId
The component identifier
folderType
The type of folder to create. If this is null, it creates a standard folder.

createContainer

The createContainer(componentId, folderType, permissions) method creates a new site container of the given type and applies the provided
permissions (a map of authorities and permissions) to the created container.

Parameters
componentId
The component identifier
folderType
The type of folder to create. If this is null, it creates a standard folder.
permissions
The permissions for the site.

deleteSite
deleteSite() deletes a site.

Example
var site = [Link]("site‐to‐delete");

if(site){

[Link]();

site = [Link]("site‐to‐delete");

if(!site){
[Link] = "Site not found!";
}
else{
[Link] = "Site found!";
}
}

Parent topic: Site object [237]

getContainer
getContainer(componentId) gets (or creates) the container folder (node) folder for the specified component identifier with the container type
cm:folder.

The type of container is either the one specified by the caller (which must be cm:folder or a subtype of), or cm:folder, if a type is not specified at
all.

Parameters
componentId
The component identifier

Returns
Returns a ScriptNode object representing the container folder, or null if the container cannot be returned or created (mostl likely due to
permissions).

Parent topic: Site object [237]

getCustomProperties
getCustomProperties() gets a map of the custom properties of the site.

Returns
Returns a map of property names and values.

Parent topic: Site object [237]

getCustomProperty
getCustomProperty(name) gets the value of a custom property (null if the custom property has not been set or does not exist).

Parameters
name
The QName of the property.

Returns
Returns the value of the property, or null if not set.

Parent topic: Site object [237]

getInvitation
getInvitation(invitationId) gets an invitation to this web site.

Parameters
invitationId
The invitation id of the invitation to return.

Returns
The ScriptInvitation object.
Parent topic: Site object [237]

getMembersRole
getMembersRole(authorityName) returns a user's role in this site.

Parameters
authorityName
A string representing the authority name.

Returns
Returns a string representing the user's role or null if not a member.

Example
The following code snippet uses getMembersRole to determine the site role of the authority "admin":
var site = [Link]("swsdp");

if(site){

var authorityName = "admin";

if([Link](authorityName)){

[Link] = authorityName;
[Link] = [Link](authorityName);

}
}

Parent topic: Site object [237]

getMembersRoleInfo
getMembersRoleInfo(authorityName) returns extended information about a user's role in this site.

Parameters
authorityName
A string representing the authority name.

Returns
Returns a SiteMemberInfo object describing the user's role, or null if the user is not a member.

Example
The following code snippet uses getMembersRoleInfo to determine the site role of the authority "admin":
var site = [Link]("swsdp");

if(site){

var authorityName = "admin";

if([Link](authorityName)){

[Link] = authorityName;
[Link] = [Link](authorityName);

}
}

Parent topic: Site object [237]

hasContainer
hasContainer(componentId) determines if the container folder for the specified component exists; if true the container folder exists.
Parameters
componentId
The component to check for existence of a container folder.

Returns
Returns a boolean, true if container folder exists, false otherwise.

Parent topic: Site object [237]

inviteModerated
The inviteModerated(inviteeComments, inviteeUserName, inviteeRole) creates a new moderated invitation to the specified web site.

Parameters
inviteeComments
String.
inviteeUserName
String.
inviteeRole
String.

Returns
A ScriptInvitation object.

Parent topic: Site object [237]

inviteNominated (new user)


inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeRole, acceptUrl, rejectUrl) creates a new nominated invitation to this
web site for a new user who might not already be an Alfresco user.

Parameters
inviteeFirstName
A string representing the invited user's first name.
inviteeLastName
A string representing the invited user's last name.
inviteeEmail
A string representing the invited user's email address.
inviteeRole
A string representing the invited user's role, for example: Manager, Collaborator, Contributor, Consumer.
acceptUrl
A string representing the URL corresponding to acceptance of the invitation.
rejectUrl
A string representing the URL corresponding to rejection of the invitation.

Returns
A ScriptInvitation object.

Parent topic: Site object [237]

inviteNominated (existing user)


inviteNominated(inviteeUserName, inviteeRole, acceptUrl, rejectUrl) creates a new nominated invitation to this web site for an existing user.

Parameters
inviteeUserName
A string representing the invitee's user name.
inviteeRole
A string representing the invited user's role, for example: Manager, Collaborator, Contributor, Consumer.
acceptUrl
A string representing the URL corresponding to acceptance of the invitation.
rejectUrl
A string representing the URL corresponding to rejection of the invitation.

Returns
A ScriptInvitation object.

Parent topic: Site object [237]

isMember
isMember(authorityName) indicates whether a user is a member of the site.

Parameters
authorityName
A string representing the user's authority name.

Returns
Boolean

This is true if the user is a member of the site, or false if otherwise.

Example
The following code snippet uses isMember to test if "admin" is a member of the site "swsdp":
var site = [Link]("swsdp");

if(site){

var authorityName = "admin";

if([Link](authorityName)){

[Link] = authorityName;
[Link] = [Link](authorityName);

}
}

Parent topic: Site object [237]

isMemberOfGroup
isMemberOfGroup(authorityName) indicates whether a user belongs to a group that has access rights to the site.

Parameters
authorityName
A string representing the user's authority name.

Returns
Boolean

This is true if the user is a member of a group that has access to this site, or false if otherwise.

Example
The following code snippet uses isMemberOfGroup to test if "[Link]" is a member of a group that has access to the site "swsdp":
var site = [Link]("swsdp");

if(site){

var authorityName = "[Link]";

if([Link](authorityName)){
...
}
}

Parent topic: Site object [237]

listInvitations
listInvitations() lists the outstanding invitations for this web site.

Returns
An array of ScriptInvitation objects.

Parent topic: Site object [237]

listInvitations(props)

listInvitations(props) this method lists the open invitations for this web site.

Parameters

props
The optional properties to search for, such as inviteeUserName and invitationType.

Returns
An array of ScriptInvitation objects.

listMembers
listMembers(nameFilter, roleFilter, size, collapseGroups) gets a map of members of the site filtered by user name and/or user role.

If no name or role filter is specified all members of the site are listed.

This list includes both users and groups if collapseGroups is set to false, otherwise all groups that are members are collapsed into their
component users and listed.

Parameters
nameFilter
User name filter string.
roleFilter
User role filter string.
size
Limit the return results to this number of items. The default, 0, returns all results.
collapseGroups
True if collapse member groups into user list; false otherwise.

Returns
Returns the list of members of a site with their roles or all site members if no name or role filter is specified.

Example
The following code snippet would return all members with no filtering, and the members of groups are also collapsed into the member list
returned:

[Link] = [Link](null, null, 0, true);

Parent topic: Site object [237]

removeMembership
removeMembership(authorityName) removes the specified user from a web project.

Parameters
authorityName
A string representing the user name of the user to remove from membership of the site.

Returns
void

Example
var site = [Link]("swsdp");

if(site){

var authorityName = "[Link]";

[Link](authorityName);

...
}

Parent topic: Site object [237]

resetAllPermissions
resetAllPermissions(node) resets any permissions that have been set on the node, deleting all permissions and setting the node to inherit
permissions.

Parameters
node
The ScriptNode object for which to reset all permissions.

Returns
void

Parent topic: Site object [237]

save
save() saves any outstanding updates to the site detail. Those changes will be lost if properties of the site change and the save method is not
called.

Example
var site = [Link]("simple‐site");

if(site){

var oldDescription = [Link];


[Link] = "A new description";
[Link]();

[Link] = oldDescription;
[Link] = [Link];
}

Parent topic: Site object [237]

setMembership
setMembership(authorityName, role) sets the membership details for a user.

If the user is not already a member of the site, then they are added with the role given. If the user is already a member of the site, then their
role is updated to the new role.

Only a site manager can modify memberships. There must be at least one site manager at all times.

Parameters
authorityName
A string representing the user's user name.
role
A string representing the role for the user.

Example
var site = [Link]("swsdp");

if(site){

var authorityName = "[Link]";


var role = "SiteContributor"; // "SiteManager", "SiteCollaborator", "SiteContributor", "SiteConsumer"

[Link](authorityName, role);

...

Parent topic: Site object [237]

setPermissions
setPermissions(node, permissions) sets permissions for a node.

Parameters
node
The ScriptNode object to set permissions for.
permissions
The permissions to set for the object.

Parent topic: Site object [237]

Tagging service
A tag is a non­hierarchical keyword or term assigned to a piece of information. The root object used to access these services is taggingService.

You must enable the auditing service and the tag audit application for taggingService to function properly. Set [Link]=true and
[Link]=true in the application configuration.

createTag [273]createTag(store, tag) creates a node representing the tag.


deleteTag [274]deleteTag(store, tag) deletes the specified tag.
getTag [275]getTag(store, tag) returns a tag node for the specified store and tag.
getTags [276] The getTags() methods get all the tags available in a store.
TagScope object [277] The tagging­related ScriptNode methods such as getTagScope return TagScope objects.

Parent topic: Services API [4]

createTag
createTag(store, tag) creates a node representing the tag.

Parameters
store
A store reference string designating the store in which to create the tag.
tag
A string designating the tag to create.

Returns
A ScriptNode object corresponding to the created tag. Null if the tag can not be created.

Example
[Link] = [Link]("workspace://SpacesStore", "cloud");
Parent topic: Tagging service [187]

deleteTag
deleteTag(store, tag) deletes the specified tag.

Parameters
store
A store reference string designating the store in which the tag is located.
tag
A string designating the tag to delete.

Returns
void

Example
if([Link]("workspace://SpacesStore", "cloud")){

[Link]("workspace://SpacesStore", "cloud");
model.message1 = "Tag successfully deleted!";

}
else {
model.message1 = "Tag does not exist!";
}

// ensure deleted

if([Link]("workspace://SpacesStore", "cloud")){
model.message2 = "Tag found!";
}
else {
model.message2 = "Tag does not exist!";
}

The preceding code snippet would result in the following messages if the tag was found and deleted:
Message1: Tag successfully deleted!

Message2: Tag does not exist!

Parent topic: Tagging service [187]

getTag
getTag(store, tag) returns a tag node for the specified store and tag.

Parameters
store
A store reference string designating the store to scan for tags.
tag
A string designating the tag to fetch.

Returns
A ScriptNode object corresponding to the specified tag. Null if tag not found.

Example
[Link] = [Link]("workspace://SpacesStore", "cold");

The preceding code snippet would return a node for the tag "cold". The node details can be displayed using the following FreeMarker template
code:

<p>${[Link]}, ${[Link]}, ${[Link]}</p>


This would display information such as:
cold, workspace://SpacesStore/0b0cbfd3‐4c2d‐4d7a‐885d‐c3ba6e471a9a, {[Link]

Parent topic: Tagging service [187]

getTags
The getTags() methods get all the tags available in a store.
Parent topic: Tagging service [187]

getTags(store)

getTags(store) gets tags from the specified store.

Parameters

store
A store reference string designating the store to scan for tags.

Returns

A string array containing the available tags.

Example

The following code snippet would return all tags in the SpacesStore:
[Link] = [Link]("workspace://SpacesStore");

The following FreeMarker template code could then enumerate the tags:

<#list tags as t>


<p>${t}</p>
</#list>

getTags(store, filter)

getTags(store, filter) gets tags from the specified store.

Parameters
store
A store reference string designating the store to scan for tags.
filter
A string used to filter the list of returned tags.

Returns

A string array containing the available tags.

Example

The following code snippet would return tags in the SpacesStore which contained the text "co":
[Link] = [Link]("workspace://SpacesStore", "co");

TagScope object
The tagging­related ScriptNode methods such as getTagScope return TagScope objects.

A TagScope object describes the tags scoped to a node.

Properties
The TagScope object type provides the following property:
tags
A read­only array containing the tag details in count order.

getCount [278]getCount(tag) gets the count of a tag; that is, how many times the tag is used within the tag scope. This is zero if the tag is
not present.
getTopTags [279]getTopTags(topN) gets the top tags ordered by count.
refresh [280]refresh() refreshes the tag scope, causing the tags and counts within the tag scope to be updated.

Parent topic: Tagging service [187]

getCount
getCount(tag) gets the count of a tag; that is, how many times the tag is used within the tag scope. This is zero if the tag is not present.

Parameters
tag
A string representing the tag to return the count for.

Example
The following code snippet would return the count for the tag "cool":
var node = [Link]("TAG_SCOPE_FOLDER/TEST_FILE_1.TXT");
if (node){

[Link] = "Node found";

var tagScope = [Link]();


if (tagScope){
[Link] = [Link];
[Link] = [Link]("cool");
}
}
else {
[Link] = "Node not found!";
}

Parent topic: TagScope object [277]

getTopTags
getTopTags(topN) gets the top tags ordered by count.

Parameters
topN
The number of top tags to return.

Returns
Returns the top tag details ordered by count.

Example
var node = [Link]("TAG_SCOPE_FOLDER/TEST_FILE_1.TXT");
if (node){

[Link] = "Node found";

var tagScope = [Link]();


if (tagScope){
[Link] = [Link];
[Link] = [Link](4);
}
}
else {
[Link] = "Node not found!";
}

The preceding code snippet would return results for tags and topTags such as the following:
Node found
Tags:

Tag: 'cool' @ 3 instances

Tag: 'ends' @ 3 instances

Tag: 'browsers' @ 2 instances

Tag: 'code' @ 2 instances

Tag: 'cold' @ 2 instances

Tag: 'first' @ 2 instances

Tag: 'fire' @ 2 instances

Tag: 'fir' @ 2 instances

Tag: 'fun' @ 1 instances

Top tags:

Tag: 'cool' @ 3 instances

Tag: 'ends' @ 3 instances

Tag: 'browsers' @ 2 instances

Tag: 'code' @ 2 instances

Parent topic: TagScope object [277]

refresh
refresh()refreshes the tag scope, causing the tags and counts within the tag scope to be updated.
Parent topic: TagScope object [277]

Thumbnail service
A thumbnail is a transformation of content into a specified destination MIME type. This is most commonly an image of a particular size, but can
also be other things, for example, a Flash rendition. The Thumbnail service transforms and maintains this thumbnail.

getMimeAwarePlaceHolderResourcePath [281]getMimeAwarePlaceHolderResourcePath(thumbnailName, mimetype) gets the resource path for


the place holder thumbnail for the given named thumbnail and the given mime type.
getPlaceHolderResourcePath [282]getPlaceHolderResourcePath(thumbnailName) gets the resource path for the place holder thumbnail for the
given named thumbnail.
isThumbnailNameRegistered [283]isThumbnailNameRegistered(thumbnailName) determines whether a given thumbnail name has been
registered.

Parent topic: Services API [4]

getMimeAwarePlaceHolderResourcePath
getMimeAwarePlaceHolderResourcePath(thumbnailName, mimetype) gets the resource path for the place holder thumbnail for the given named
thumbnail and the given mime type.

If there is no icon available for the specified MIME type, a generic icon will be used instead. The generic icon is that returned by
getPlaceHolderResourcePath(String). If neither a MIME­specific icon nor a generic icon is available, null is returned.

Parameters
thumbnailName
A string representing the thumbnail name.
mimetype
A string representing the mimetype of the piece of content.

Returns
Returns a string of placeholder thumbnail resource path (null if it is not set).
Parent topic: Thumbnail service [188]

getPlaceHolderResourcePath
getPlaceHolderResourcePath(thumbnailName) gets the resource path for the place holder thumbnail for the given named thumbnail.
Parameters
thumbnailName
A string representing the thumbnail name.

Returns
Returns a string of placeholder thumbnail resource path (null if it is not set).
Parent topic: Thumbnail service [188]

isThumbnailNameRegistered
isThumbnailNameRegistered(thumbnailName) determines whether a given thumbnail name has been registered.

Parameters
thumbnailName
A string representing the thumbnail name.

Returns
Returns true if the thumbnail name is registered. Otherwise it returns false.
Parent topic: Thumbnail service [188]

Workflow service
The Workflow JavaScript API lets you access Alfresco advanced workflows from within JavaScript.
This API provides the ability to:

Access and manage workflow definitions, instances, paths, tasks, and transitions
Create workflow packages
Start, cancel, or delete workflow instances
End and progress workflow paths to the next node with a specified transition

Note: The object model for this API is similar to that of the Advanced Workflow Java API. The relationships between the various types used in
this API are the same as the relationships between the various classes used in the Advanced Workflow API. Each class in the Workflow
JavaScript API mirrors a class in the Advanced Workflow API, however, the JavaScript classes are simpler, making them more easily
accessible from JavaScript. All the JavaScript classes implement the Serializable interface, which allows them to be stored in Scriptable
objects.

JscriptWorkflowDefinition [284] The workflow definition is the type (or template) of a workflow process. A workflow process definition
relates to a workflow instance like a Java class definition relates to an instance of that class. You can use the workflow definition to create
and start new workflow instances of that type, as well as to find all currently active instances of that type.
JscriptWorkflowInstance [285] The workflow instance holds various data about a workflow such as its start date, due date, current state,
and so on. A workflow instance can be cancelled (made inactive), or deleted.
JscriptWorkflowNode [286] A workflow node is a single point in the workflow process. Some workflow nodes are task nodes with
associated tasks that must be completed before the workflow can transition to the next node.
JscriptWorkflowPath [287] The workflow path represents the current state (position) of a workflow instance.
JscriptWorkflowTask [288] JscriptWorkflowTask represents a specific instance of a workflow task as opposed to a workflow task definition
(the task type). A workflow task instance represents a user action, which is usually something that cannot be automated in the workflow.
JscriptWorkflowTransition [289] The workflow transition is a simple Data Transfer Object (DTO) representing a single transition type.
Workflow Manager [290] The Workflow Manager is the entry point to the Workflow JavaScript API. It is the only object in this API exposed
to the root scripting scope. In the root scripting scope, the WorkflowManager object is identified as workflow.

Parent topic: Services API [4]

JscriptWorkflowDefinition
The workflow definition is the type (or template) of a workflow process. A workflow process definition relates to a workflow instance like a Java
class definition relates to an instance of that class. You can use the workflow definition to create and start new workflow instances of that type,
as well as to find all currently active instances of that type.

Properties
id
Returns an ID for this workflow definition
name
Returns a string name for this workflow definition
version
Returns a version number for this workflow definition
title
Returns a title for this workflow definition
description
Returns a description for this workflow definition
activeInstances
Returns an array of all active workflow instances for this workflow definition.

startWorkflow [291] The startWorkflow() methods create and start a new workflow instance of the workflow definition type.

Parent topic: Workflow service [189]

startWorkflow
The startWorkflow() methods create and start a new workflow instance of the workflow definition type.
Parent topic: JscriptWorkflowDefinition [284]

startWorkflow(properties)

startWorkflow(properties) this method creates and starts a new workflow instance of the workflow definition's type.

Parameters

properties
If not of type ScriptableObject, the properties parameter will be ignored

Returns

Returns the workflow path (JscriptWorkflowPath) for the created instance. This method does not set a package container.

startWorkflow(workflowPackage, properties)

startWorkflow(properties) this method creates and starts a new workflow instance of the workflow definition's type.

Parameters

workflowPackage
Workflow package node to attach to the new workflow.
properties
If not of type ScriptableObject, the properties parameter will be ignored

Returns
Returns the workflow path (JscriptWorkflowPath) for the created instance.

JscriptWorkflowInstance
The workflow instance holds various data about a workflow such as its start date, due date, current state, and so on. A workflow instance can
be cancelled (made inactive), or deleted.

Properties
active
Returns true if the workflow instance is in progress, or false otherwise
description
Returns the description for this workflow instance
endDate
Returns the date when this workflow instance ended
id
Returns the ID for this workflow instance
paths
Returns an array containing all the paths associated with this workflow instance
startDate
Returns the date when this workflow instance started

cancel [292]cancel() cancels the workflow instance.


remove [293]remove() removes the workflow instance.

Parent topic: Workflow service [189]


cancel
cancel()cancels the workflow instance.
Parent topic: JscriptWorkflowInstance [285]

remove
remove()removes the workflow instance.
Parent topic: JscriptWorkflowInstance [285]

JscriptWorkflowNode
A workflow node is a single point in the workflow process. Some workflow nodes are task nodes with associated tasks that must be completed
before the workflow can transition to the next node.

Properties
description
Returns the description for this workflow node
isTaskNode
Returns true if this node is a task node, or false otherwise
name
Returns the name when this workflow node
title
Returns the title for this workflow node
transitions
Returns the list of transitions that are available for this node

Parent topic: Workflow service [189]

JscriptWorkflowPath
The workflow path represents the current state (position) of a workflow instance.

The path stores the current position in the workflow as well as the path taken through the workflow to reach this point. An in­progress workflow
can have multiple workflow paths if the process contains any forking nodes. The workflow path can be signaled to transition to the next node in
the process.

Properties
active
Returns true if this node is a task node, or false otherwise
id
Returns the ID for this workflow path
instance
Returns the workflow instance to which this workflow path belongs
node
Returns the current node (position) of the workflow path
tasks
Returns an array of all the tasks associated with this workflow path

signal [294]signal(transitionId) signals the workflow path to transition to the next node.

Parent topic: Workflow service [189]

signal
signal(transitionId) signals the workflow path to transition to the next node.

Parameters
transitionId
ID of the transition to follow (or null, for the default transition)

Returns
Returns JscriptWorkflowPath object representing the newly transitioned workflow path
Parent topic: JscriptWorkflowPath [287]

JscriptWorkflowTask
JscriptWorkflowTask represents a specific instance of a workflow task as opposed to a workflow task definition (the task type). A workflow task
instance represents a user action, which is usually something that cannot be automated in the workflow.

Task instances can be associated with workflow nodes within the process definition. When the workflow path reaches a node with an
associated task, it will not progress until the task is complete and the user signals a transition. A workflow task instance can be signaled with a
transition causing the workflow path to progress to the next node with the specified transition.

Some typical examples of where tasks might be used include reviewing and approving documents, editing and appending documents, and
marking exam papers.

Properties
complete
Returns whether the task is complete or not. True means the task is complete, false not complete.
description
Returns the description for the workflow task instance
id
Returns the ID for the workflow task instance
name
Returns the name for the workflow task instance
packageResources
Returns an array of NodeRefs of the content stored in the package container associated with this workflow task instance
pooled
Gets or sets if this is a pooled task instance or not (true or false). A pooled task instance can be assigned to a group of users, of which
one can take ownership and progress the task
properties
Gets or sets a map containing all the properties associated with this task instance
title
Returns the title for the workflow task instance
transitions
Returns a map containing all the transition IDs (map keys) and transition titles (map values) for the task instance

endTask [295]endTask(transitionId) ends the task and signals the associated workflow path to progress to the next node using the
specified transition.

Parent topic: Workflow service [189]

endTask
endTask(transitionId) ends the task and signals the associated workflow path to progress to the next node using the specified transition.

Parameters
transitionId
ID of the transition to end the task for.

Returns
void

Parent topic: JscriptWorkflowTask [288]

JscriptWorkflowTransition
The workflow transition is a simple Data Transfer Object (DTO) representing a single transition type.

Properties
description
Returns the description for the workflow transition
id
Returns the ID for the workflow transition
title
Returns the title for the workflow transition

Parent topic: Workflow service [189]


Workflow Manager
The Workflow Manager is the entry point to the Workflow JavaScript API. It is the only object in this API exposed to the root scripting scope. In
the root scripting scope, the WorkflowManager object is identified as workflow.

Properties
allDefinitions
Returns an array of all (old and current) versions of deployed workflow definitions For current versions only, use latestDefinitions.
assignedTasks
Returns an array of all tasks that are currently in progress assigned to the current user.
completedTasks
Returns an array of all completed tasks assigned to the current user.
latestDefinitions
Returns an array of the latest version of all deployed workflow definitions For all versions, use allDefinitions.

createPackage [296]createPackage() creates a package. A package is a container node that can store content associated with a workflow
instance.
getAllDefinitions [297]getAllDefinitions() ­ Returns all versions of the deployed workflow definitions.
getAssignedTasks [298]getAssignedTasks() ­ Get tasks assigned to the current user. Note that this will only return in­progress tasks.
getCompletedTasks [299]getCompletedTasks() ­ Get completed tasks assigned to the current user.
getDefinition [300]getDefinition(id) returns a workflow definition with the specified ID.
getDefinitionByName [301]getDefinitionByName(name) gets the workflow definitions corresponding to the specified name.
getInstance [302]getInstance(workflowInstanceId) gets the workflow instance with the specified ID.
getLatestDefinitions [303]getLatestDefinitions() ­ Gets the latest versions of the deployed, workflow definitions.
getPooledTasks [304]getPooledTasks(authority) gets pooled workflow task instances available to the given authority.
getTask [305]getTask(id) returns the workflow task instance with the specified ID.
getTaskById [306]getTaskById(id) returns the workflow task instance with the specified ID.

Parent topic: Workflow service [189]

createPackage
createPackage() creates a package. A package is a container node that can store content associated with a workflow instance.

Returns
Returns a ScriptNode object corresponding to the created container.

Parent topic: Workflow Manager [290]

getAllDefinitions
getAllDefinitions() ­ Returns all versions of the deployed workflow definitions.

Parameters
None

Returns
Returns all versions of the deployed workflow definitions.

Example

[Link] = [Link]();

Parent topic: Workflow Manager [290]

getAssignedTasks
getAssignedTasks() ­ Get tasks assigned to the current user. Note that this will only return in­progress tasks.

Parameters
None

Returns
Returns the list of assigned (in­progress) tasks.

Example

[Link] = [Link]();

Parent topic: Workflow Manager [290]

getCompletedTasks
getCompletedTasks() ­ Get completed tasks assigned to the current user.

Parameters
None

Returns
Returns the list of completed tasks.

Example
[Link] = [Link]();

Parent topic: Workflow Manager [290]

getDefinition
getDefinition(id) returns a workflow definition with the specified ID.

Parameters
id
A string representing the ID of the workflow definition.

Returns
Returns the workflow definition with the given ID. Returns null if no workflow definition with the given ID exists.

Example
var id = "activiti$activitiAdhoc:1:4";

[Link] = [Link](id);

Parent topic: Workflow Manager [290]

getDefinitionByName
getDefinitionByName(name) gets the workflow definitions corresponding to the specified name.

Parameters
name
A string representing the name of the workflow definition to return.

Returns
Returns the workflow definition with the given name or null if no workflow definition with the given name exists.
Example
var name = "activiti$activitiAdhoc";

[Link] = [Link](name);

Parent topic: Workflow Manager [290]

getInstance
getInstance(workflowInstanceId) gets the workflow instance with the specified ID.

Parameters
workflowInstanceId
A string representing the ID of the workflow instance.

Returns
Returns the workflow instance with the given ID or null if no workflow instance with the given ID exists.

Example
var id = "activiti$164";

[Link] = [Link](id);

Parent topic: Workflow Manager [290]

getLatestDefinitions
getLatestDefinitions() ­ Gets the latest versions of the deployed, workflow definitions.

Parameters
None

Returns
Returns the latest versions of the deployed, workflow definitions.

Example

[Link] = [Link]();

Parent topic: Workflow Manager [290]

getPooledTasks
getPooledTasks(authority) gets pooled workflow task instances available to the given authority.

A pooled task can be assigned to a group of users, and then one of those users may take ownership and progress the task.

Parameters
authority

Returns
Returns an array of the pooled workflow task instances available to the given authority.

Example
[Link] = [Link]("GROUP_SUPERUSERS");

Parent topic: Workflow Manager [290]

getTask
getTask(id) returns the workflow task instance with the specified ID.

Parameters
id
The ID of the workflow task instance.

Returns
Returns the workflow task instance with the specified ID. Returns null if no workflow task instance with the given ID exists.

Example
var taskId = "activiti$144";

[Link] = [Link](taskId);

Parent topic: Workflow Manager [290]

getTaskById
getTaskById(id) returns the workflow task instance with the specified ID.

This method is functionally equivalent to the getTask(id) method.

Parameters
id
The ID of the workflow task instance.

Returns
Returns the workflow task instance with the specified ID. Returns null if no workflow task instance with the given ID exists.

Example
var taskId = "activiti$144";

[Link] = [Link](taskId);

Parent topic: Workflow Manager [290]

Source URL: [Link]

Links:
[1] [Link]
[2] [Link]
[3] [Link]
[4] [Link]
[5] [Link]
[6] [Link]
[7] [Link]
[8] [Link]
[9] [Link]
[10] [Link]
[11] [Link]
[12] [Link]
[13] [Link]
[14] [Link]
[15] [Link]
[16] [Link]
[17] [Link]
[18] [Link]
[19] [Link]
[20] [Link]
[21] [Link]
[22] [Link]
[23] [Link]
[24] [Link]
[25] [Link]
[26] [Link]
[27] [Link]
[28] [Link]
[29] [Link]
[30] [Link]
[31] [Link]
[32] [Link]
[33] [Link]
[34] [Link]
[35] [Link]
[36] [Link]
[37] [Link]
[38] [Link]
[39] [Link]
[40] [Link]
[41] [Link]
[42] [Link]
[43] [Link]
[44] [Link]
[45] [Link]
[46] [Link]
[47] [Link]
[48] [Link]
[49] [Link]
[50] [Link]
[51] [Link]
[52] [Link]
[53] [Link]
[54] [Link]
[55] [Link]
[56] [Link]
[57] [Link]
[58] [Link]
[59] [Link]
[60] [Link]
[61] [Link]
[62] [Link]
[63] [Link]
[64] [Link]
[65] [Link]
[66] [Link]
[67] [Link]
[68] [Link]
[69] [Link]
[70] [Link]
[71] [Link]
[72] [Link]
[73] [Link]
[74] [Link]
[75] [Link]
[76] [Link]
[77] [Link]
[78] [Link]
[79] [Link]
[80] [Link]
[81] [Link]
[82] [Link]
[83] [Link]
[84] [Link]
[85] [Link]
[86] [Link]
[87] [Link]
[88] [Link]
[89] [Link]
[90] [Link]
[91] [Link]
[92] [Link]
[93] [Link]
[94] [Link]
[95] [Link]
[96] [Link]
[97] [Link]
[98] [Link]
[99] [Link]
[100] [Link]
[101] [Link]
[102] [Link]
[103] [Link]
[104] [Link]
[105] [Link]
[106] [Link]
[107] [Link]
[108] [Link]
[109] [Link]
[110] [Link]
[111] [Link]
[112] [Link]
[113] [Link]
[114] [Link]
[115] [Link]
[115] [Link]
[116] [Link]
[117] [Link]
[118] [Link]
[119] [Link]
[120] [Link]
[121] [Link]
[122] [Link]
[123] [Link]
[124] [Link]
[125] [Link]
[126] [Link]
[127] [Link]
[128] [Link]
[129] [Link]
[130] [Link]
[131] [Link]
[132] [Link]
[133] [Link]
[134] [Link]
[135] [Link]
[136] [Link]
[137] [Link]
[138] [Link]
[139] [Link]
[140] [Link]
[141] [Link]
[142] [Link]
[143] [Link]
[144] [Link]
[145] [Link]
[146] [Link]
[147] [Link]
[148] [Link]
[149] [Link]
[150] [Link]
[151] [Link]
[152] [Link]
[153] [Link]
[154] [Link]
[155] [Link]
[156] [Link]
[157] [Link]
[158] [Link]
[159] [Link]
[160] [Link]
[161] [Link]
[162] [Link]
[163] [Link]
[164] [Link]
[165] [Link]
[166] [Link]
[167] [Link]
[168] [Link]
[169] [Link]
[170] [Link]
[171] [Link]
[172] [Link]
[173] [Link]
[174] [Link]
[175] [Link]
[176] [Link]
[177] [Link]
[178] [Link]
[179] [Link]
[180] [Link]
[181] [Link]
[182] [Link]
[183] [Link]
[184] [Link]
[185] [Link]
[186] [Link]
[187] [Link]
[188] [Link]
[189] [Link]
[190] [Link]
[191] [Link]
[192] [Link]
[193] [Link]
[194] [Link]
[195] [Link]
[196] [Link]
[197] [Link]
[198] [Link]
[199] [Link]
[200] [Link]
[201] [Link]
[202] [Link]
[203] [Link]
[204] [Link]
[205] [Link]
[206] [Link]
[207] [Link]
[207] [Link]
[208] [Link]
[209] [Link]
[210] [Link]
[211] [Link]
[212] [Link]
[213] [Link]
[214] [Link]
[215] [Link]
[216] [Link]
[217] [Link]
[218] [Link]
[219] [Link]
[220] [Link]
[221] [Link]
[222] [Link]
[223] [Link]
[224] [Link]
[225] [Link]
[226] [Link]
[227] [Link]
[228] [Link]
[229] [Link]
[230] [Link]
[231] [Link]
[232] [Link]
[233] [Link]
[234] [Link]
[235] [Link]
[236] [Link]
[237] [Link]
[238] [Link]
[239] [Link]
[240] [Link]
[241] [Link]
[242] [Link]
[243] [Link]
[244] [Link]
[245] [Link]
[246] [Link]
[247] [Link]
[248] [Link]
[249] [Link]
[250] [Link]
[251] [Link]
[252] [Link]
[253] [Link]
[254] [Link]
[255] [Link]
[256] [Link]
[257] [Link]
[258] [Link]
[259] [Link]
[260] [Link]
[261] [Link]
[262] [Link]
[263] [Link]
[264] [Link]
[265] [Link]
[266] [Link]
[267] [Link]
[268] [Link]
[269] [Link]
[270] [Link]
[271] [Link]
[272] [Link]
[273] [Link]
[274] [Link]
[275] [Link]
[276] [Link]
[277] [Link]
[278] [Link]
[279] [Link]
[280] [Link]
[281] [Link]
[282] [Link]
[283] [Link]
[284] [Link]
[285] [Link]
[286] [Link]
[287] [Link]
[288] [Link]
[289] [Link]
[290] [Link]
[291] [Link]
[292] [Link]
[293] [Link]
[294] [Link]
[295] [Link]
[296] [Link]
[297] [Link]
[298] [Link]
[299] [Link]
[299] [Link]
[300] [Link]
[301] [Link]
[302] [Link]
[303] [Link]
[304] [Link]
[305] [Link]
[306] [Link]

You might also like