AnsweredAssumed Answered

Delete the downloaded file

Question asked by landerigeno on Aug 20, 2009
Hello:
I have to develop in alfresco a feature that delete a document once the user download it.
Right now I'm triying:

I create a new Aspect toDelete and works fine.
I want to execute an scrpt each time I download a file so I edit web-client-config-actions.xml
 <!– Download document –>
         <action id="download_doc">
             <label-id>download_doc</label-id>
             <image>/images/icons/download_doc.gif</image>          
    <permissions>
               <permission allow="true">Write</permission>
            </permissions>
            <params>
               <param name="ref">#{actionContext.nodeRef}</param>
            </params>      
            <script>/Company Home/Diccionario de datos/Scripts/addaspect.js</script>
        <href>#{actionContext.downloadUrl}</href>
         </action>

And also create an script addaspect.js:
var nodeRef = args[0];
var document = search.findNode(nodeRef);
props = new Array(1);
props["cm:toDelete"] = true;
document.addAspect("cm:toDelete", props);
document.save;

I will have a schedule job to delete each file with the aspect toDelete but I can't make the script work correctlly.
Someone can help me? There is another way to do it? It's the script correct?
Thank you

Outcomes