Publish document to Alfresco Folder

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

Publish document to Alfresco Folder

Hello All,

I am new to Alfresco and i am trying  to put a document inside a folder , but my folder is a variable so using "Publish to Alfresco task " is not going to work because the destination is fixed or at max you can define only 1 subfolder.

So i am thinking of using a listener at the end of my task execution and here is the code :

var test = execution.getVariable('DocumentPath');
var strDestFolder ="sites/swsdp/Projects";
var objDestFolder = companyhome.childByNamePath(strDestFolder);
test.move(objDestFolder);

the code is not working and i am having this error : org.activiti.engine.ActivitiException: problem evaluating script: ReferenceError: "companyhome" is not defined in <eval> at line number 3.

Any body can help me in fix this code ? or providing me with a solution to putting a document in a variable folder path ?

6 Replies
Established Member II

Re: Publish document to Alfresco Folder

I think your script you have put is not correct it seems and something is undefined. like  companyhome where this variable is declared or used.

Member II

Re: Publish document to Alfresco Folder

Hello Tabrez,

I know that there is an issue with the code, i am not able to figure it out. I am searching for any solution to publish a document to a path i specify each time (variable folder path)

Senior Member

Re: Publish document to Alfresco Folder

Are you trying to publish a document from APS or Embedded Activiti in Alfresco

for APS: you need to create a REST API (webscript) in alfresco which you can call from your APS, the script in alfresco should do the publishing.

for Embedded Activiti: you must use "org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate" class in `activiti:class` for accessing Alfresco root objects such as `companyhome`

Regards,
Abbas
Member II

Re: Publish document to Alfresco Folder

Hello Abbas, 

Thanks for the feedback , but i am trying to set a rule now.. and i am unable to get a specific property from a custom type i created 

var name = document.properties["ptSmiley Tonguerojectname"]; it returns null any idea please?

Senior Member

Re: Publish document to Alfresco Folder

do you see this property applied on the document in UI? probably the property is not available when you are trying to access it.

Regards,
Abbas
Member II

Re: Publish document to Alfresco Folder

I am actually able to see it ...and it really is a weird behaviour , i put the property via APS.. and i can see it in the document...but when i try to show it , it doesnt work.