cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a ParentNodeRef

croc
Champ in-the-making
Champ in-the-making
Hi,

Is it possible to get a ParentNodeRef using node or a nodeRef?

Thanx,
Croc
4 REPLIES 4

mikeh
Star Contributor
Star Contributor
Not from the Share web tier with just a nodeRef; it's a string. You'd have to call across to a Repository webscript.

If you really have got a node (e.g. you're within a Repository webscript) then use node.parent.nodeRef.

Thanks,
Mike

croc
Champ in-the-making
Champ in-the-making
it didn't work.

Mayb let me explain my problem.  I have copied the reference from RM to DM.

I get problems after clicking the Manage Button.
Manage References: null
and the URL is: http://localhost:8080/share/page/site/SimpleSite/rmreferences?nodeRef=workspace://SpacesStore/bfad6dff-190c-40b9-b0b2-15a4773d841f&parentNodeRef={parentNodeRef}&docName=null .The parentNodeRef={parentNodeRef} and docName=null, which i think is the main cause of the problem.
Check the Code below, I didn't change anything from dod5015-document-references.js

      /**
       * Event handler for documentDetailsAvailable bubbling event
       *
       * @method onDocumentDetailsAvailable
       * @param e {object} Event
       * @param args {object} Event arguments
       */
      onDocumentDetailsAvailable: function RecordsDocumentReferences_onDocumentDetailsAvailable(e, args)
      {
         var docDetails = args[1].documentDetails;

         this.options.parentNodeRef = args[1].metadata.filePlan.replace(':/','');
         this.options.docName = docDetails.displayName;

         if (docDetails.permissions.userAccess.Create && docDetails.type !== "metadata-stub")
         {
            this.widgets.manageRefs.set("disabled", false);
         }
      },
     
      /**
       * Mange References button click handler. Redirects browser to Manage References page
       *
       * @method onManageReferences
       */
      onManageReferences: function RecordsDocumentReferences_onManageReferences()
      {
         var uriTemplate = Alfresco.constants.URL_PAGECONTEXT + 'site/{site}/rmreferences?nodeRef={nodeRef}&parentNodeRef={parentNodeRef}&docName={docName}',    
            url = YAHOO.lang.substitute(uriTemplate,
            {
               site: encodeURIComponent(this.options.siteId),
               nodeRef: this.options.nodeRef,
               parentNodeRef: this.options.parentNodeRef,
               docName: encodeURIComponent(this.options.docName)
            });

         window.location.href = url;
      }

What do you think might be the reason for not passing the correct parentNode and docName?

Thanx,
Croc

mikeh
Star Contributor
Star Contributor
You can't use the RM Share webscripts on non-RM sites, as the JSON response from the Repository data webscripts is different. As you can see from the code, it's trying to get parentNodeRef from args[1].metadata.filePlan. However "filePlan" is an RM-only property which is why the code's failing.

You should be able to find the parentNodeRef in args[1].metadata.parent.nodeRef.

Thanks,
Mike

croc
Champ in-the-making
Champ in-the-making
Thank you very much Mike, it is working.