cancel
Showing results for 
Search instead for 
Did you mean: 

copy content to another location under a different name

tb13
Champ in-the-making
Champ in-the-making
Hi I want to copy a document from a folder in the repos to a site doclib, however in the doclib I want to rename it to another name.
The use:
Creating a document from a template file in a working directory of a site, whereas the template files reside in repository folder outside the site.

Is there a doclib webscript that does that? I have checked but found none. How could I go about doing that?

Thanks for your precious help 🙂
2 REPLIES 2

zaizi
Champ in-the-making
Champ in-the-making
Create a custom webscript to copy and rename the document. Call the webscript with source and destination arguments to do it.

Ainga

tb13
Champ in-the-making
Champ in-the-making
Ok copy rename would be done e.g. in the following way using the Alfresco 3.4 JS API:

Serverside JS webscript:

function copyRenameFolder(path, destNode, newName) {
      templateNode = companyhome.childByNamePath(path);   
     
      if(destNode.isContainer) {    
         if(templateNode.isContainer) {
                           //Copy node from a path to destNode and get the newNode at the new location as a ScriptNode   
            var newNode = templateNode.copy(destNode, true);
                           //Change the name of newNode
            newNode.name = newName;

            model.success = "true";
         }
         else {
            model.success = "false";
         }  
      }
      else {
         model.success = "false";
      }
}