Accessing parent folder of a document in workflow script

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2014 05:48 AM
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
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
Labels:
- Labels:
-
Archive
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2014 07:06 AM
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.
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.
