Search code examples
alfrescoyuialfresco-share

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?


Solution

  • 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.