AnsweredAssumed Answered

Javascript problem - add document to package

Question asked by sims on Jul 16, 2014
Hello Alfresco team,

I have a problem with my javascript code on a workflow task, it works once two, i just want to add my new generate file on my bpm_package.
When i sign a document, that generate a new file in a the folder that contain the source file.
Exemple : source file = "doc.pdf", sign file = "doc-1.pdf".
Here is my code : the part that does not work is the lat part with the If condition.

<javascript>for(var i = 0; i < bpm_package.children.length; i++)
   var jSstring;
   jSstring = new String(;
   var temp= new Array();
   temp= jSstring.split('.'); //split files, get the name before .
   var name_file= temp[0] + "-1.pdf";
   var foundNode=search.luceneSearch("@cm\\:folder:'"+bpm_package.children.displayPath+"'" + "AND @cm\\:name:'"+name_file+"'"); //find the node from our file
      for(var u = 0; u < bpm_package.children.length; u++)
      var nom = new String(;
      if(foundNode[0]!=null && foundNode[0]!="" && foundNode[0]!== 'Undefined')
         bpm_package.addNode(foundNode[0]); //add the node to the package
         for(var indice = 0; indice < bpm_package.children.length; indice++)
         var nom_final = new String(bpm_package.children[indice].name);
               bpm_package.children[indice].name=temp[0]+"_sign.pdf"; //if we find a name-1.pdf, rename to name_sign.pdf

Thx for your help !