AnsweredAssumed Answered

Problem while crossrepocopy through WCM submit workflow

Question asked by amarpalkaur on Jul 1, 2008
Latest reply on Jul 2, 2008 by amarpalkaur

I am customizing WCM submit workflow to add some behavior to task transitions. In customized workflow, when content gets approved and content creator clicks on ‘task done’, I am trying to copy the newly created or modified content to ‘companyhome/HDS’ folder. For fulfilling this, I am making a call to crossrepocopy.copy(). But my problem is this whole java script code works fine when creator is ‘admin’ where as in case of user with role ‘content contributor’, crossrepocopy.copy throws org.alfresco.service.cmr.avm.AVMNotFoundException: Path not found exception. I am not able to find out the cause of the problem.

Here is my java script action used in workflow :-

<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">

/* Path of WCM file to copy in ECM  */
var nodepaths = ml.getNodepath();

/* As there may be multiple documents in the workflow*/
var downloadFrom = new Array(nodepaths.length);

for(var x=0; nodepaths.length >x;x++)
/* Creating actual path of file from staging sandbox */
var nodepath = nodepaths[x];
var inx = nodepath.indexOf(":");
nodepath =nodepath.substring(inx+1);
/* Get the source node to be copied */
var srcnode = avm.lookupNode(“hds–"["cm:userName"]+nodepath);
/* Here path is like “hds—admin:/www/avm_webapps/ROOT/filename.xml” */

/* Getting the folder structure (to find the destination in ECM) */
var rootindx = nodepath.indexOf("ROOT");
nodepath   = nodepath.substring(rootindx+5);
var slashindx = nodepath.lastIndexOf("/");
nodepath   = nodepath.substring(0, slashindx);
/* Find the destination folder in ECM */       
nodepath = "HDS/"+nodepath;
       nodepath = "HDS";

var destFolder = companyhome.childByNamePath(nodepath);
java.lang.System.out.println(;      /*Till here the script executes*/ 
crossRepoCopy.copy(srcnode,destFolder,"File to copy");
var ts = new java.util.Date();
var appendtoname = ts.toString().replace(':','_');      
/* Rename the copied node to include current time stamp (Versioning alternative) */
destFolder = companyhome.childByNamePath(nodepath);
destChild = destFolder.children;   
for(var i = 0; destChild.length > i; i++)
      var tkens = (".");                  
       = tkens[0]+"_"+appendtoname+"."+tkens[1];         
      existingNode = destChild;

Please provide some clue to solve the issue.
Thanks in advance

Amarpal Kaur