cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing parent folder of a document in workflow script

ssdev
Champ in-the-making
Champ in-the-making
Hi,

I have a custom workflow in which I run the following script

<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
    <activiti:field name="script">
        <activiti:string>
            var document = bpm_package.children[0];

            var siteName = document.siteShortName;
                              
       var folderPath = "Sites/" + siteName + "/documentLibrary/Completed";
                    
       var folder = companyhome.childByNamePath(folderPath);

       document.move(folder);
         </activiti:string>
     </activiti:field>
</activiti:executionListener>

Currently I am using the command 'document.move(folder)' to move the document linked to the workflow. However I would like to move the whole parent folder that the document is in. Is there are commend that I can use to access the document's parent folder from here?

I have tried document.properties.parent but this returned null? Has anybody had the same issue or have an idea of a command which can retrieve the parent node of document?

Thanks
1 REPLY 1

ssdev
Champ in-the-making
Champ in-the-making
I resolved the issue by simply using document.parent to get access to the parent folder.

What I had not figured out was that the document is an object of the ScriptNode API http://docs.alfresco.com/4.2/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FAPI-JS-Sc.... In this API, the parent command can be used to access the parent node.