BlueStar
BlueStar

Reputation: 411

How to refer to a child nodeRef in Alfresco-share?

I am working on a custom doclib javascript. I have a folder structure which is similar to A --> B --> C where A and B have multiple children. I have the noderef of the folder A which I have found out through

"this.doclistMetadata.parent.nodeRef"

What is the easiest way to get the uri from the Node "C" while staying at Node A level? Can file path be used for this purpose?

Upvotes: 0

Views: 729

Answers (2)

kinjelom
kinjelom

Reputation: 6450

You should get ScriptNode object (ScriptNode class):

var A = this.doclistMetadata.parent;
// or by nodeRef
// var A =  search.findNode("workspace://SpacesStore/abcdefg-your-A-folder-id");

and use ScriptNode API

var C = A.childByNamePath("B/C");
print(C.name+" nodeRef: "+C.nodeRef.toString());
print(C.name+" children: "+C.childFileFolders());

It works for any ScriptNode object, virtual/smart folders too.

Upvotes: 2

PRVS
PRVS

Reputation: 1690

I think that you can use this:

For example, in the workflows, you can search for an element with the id "page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems". If there is more than one document associated, the value will be a comma separated list of noderefs.

var nodeRef = YAHOO.util.Selector.query("#page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems")[0].value;

Using the browser debug tool, you can inspect the html. As you can see in the image attached below, Alfresco stores the documents attached to the task in an hidden input. You could use YAHOO to get it.

enter image description here

(Source: https://stackoverflow.com/a/35257692/4337310)

Upvotes: 0

Related Questions