Node
Provides scripting facilities around a Node.
Properties
Name | Type | Description |
---|---|---|
|
|
All of the associations around a node. |
|
|
The attachments for the node |
|
|
The Branch on which this Association resides. |
|
|
The ID of the branch that this Association resides on. |
|
|
The changeset ID on which this node resides. If the node has not yet been saved, this may be null. |
|
|
All of the child associations around a node |
|
|
All of the children of a node. This hands back the target nodes that are related by |
|
|
The Description of this document. |
|
|
The ID of this document. |
|
|
The parent of a node (as related by |
|
|
The properties for this document. |
|
|
The Repository on which this Association resides. |
|
|
The ID of the repository that this Association resides on. |
|
|
The Title of this document. |
|
|
The Type QName of the node (as a string) |
|
|
The Type QName of the node. |
Methods
addFeature
Usage
void addFeature()
Arguments
None
Return
Type | Description |
---|---|
|
associate
Usage
void associate()
Arguments
None
Return
Type | Description |
---|---|
|
Examples
Simple Association
In this code sample, we associate a node to a target node using the a:child
association type.
var targetNode = branch.readNode("some_guid");
var association = node.associate(targetNode, "a:child");
Directed Association with Properties
In this code sample, we associate this node from a source node a:child
association type and some custom properties. The custom properties are stored on the association.
var sourceNode = branch.readNode("some_guid");
var object = {
"weight": 3
};
var association = node.associate(targetNode, "a:child", "INCOMING", object);
del
Usage
void del()
Arguments
None
Return
Type | Description |
---|---|
|
findAssociations
Usage
resultmap findAssociations()
Arguments
None
Return
Type | Description |
---|---|
|
Examples
In this code sample, we find any incoming associations for a node that are of type a:child
. These associations start from a different node and point to our node.
var associations = node.findAssociations({
"direction": "INCOMING",
"type": "a:child"
});
The associations
object is a key/value map where each key is the ID of an association. The value is the association itself.
for (var id in associations)
{
var association = associations[id];
logger.info("Found association: " + association.stringify(true));
}
getFeature
Usage
object getFeature()
Arguments
None
Return
Type | Description |
---|---|
|
getIsContainer
Usage
whether the node is a container of "child" nodes getIsContainer()
Arguments
None
Return
Type | Description |
---|---|
|
getIsLocked
Usage
whether the node is locked getIsLocked()
Arguments
None
Return
Type | Description |
---|---|
|
getPath
Usage
the default filefolder path for this node getPath()
Arguments
None
Return
Type | Description |
---|---|
|
Examples
In this code sample, we configure a script action for a rule bound with the p:afterAssociatePolicy which will apply a _path property to the target node if it has type my:thing
:
function execute(association)
{
var node = association.getTargetNode();
if ("my:thing" === String(node.getType()))
{
logger.info("Applying path property for: " + node.getId());
var path = node.getPath();
if (path)
{
node.data["_path"] = path;
node.save();
}
}
}
reload
Usage
void reload()
Arguments
None
Return
Type | Description |
---|---|
|
Examples
In this code sample, we make changes to a node and then reload to restore the original values.
// set the title to "Original Title"
node.properties.title = "Original Title";
node.save();
// change the title
node.properties.title = "Changed Title";
// reload
node.reload();
// the title is now "Original Title"
var test = (node.properties.title == "Original Title");
// test is true
remove
Usage
void remove()
Arguments
None
Return
Type | Description |
---|---|
|
removeFeature
Usage
void removeFeature()
Arguments
None
Return
Type | Description |
---|---|
|
save
Usage
void save()
Arguments
None
Return
Type | Description |
---|---|
|
Examples
In this code sample, we make changes to a node and save the changes.
node.properties.title = "The new title of my node";
node.properties.category = "red";
node.save();
stringify
Usage
string stringify()
Arguments
None
Return
Type | Description |
---|---|
|
Examples
In this code sample, we take the JSON for the given document and produce a string representation of it.
var text = document.stringify(true);
update
Usage
void update()
Arguments
None
Return
Type | Description |
---|---|
|