cancel
Showing results for 
Search instead for 
Did you mean: 

Finding a newly created node

joakims
Champ in-the-making
Champ in-the-making
Hi,

First of all, I'm very new to Alfresco and my java skills are fairly (very) rusty. Anyway; my goal is to create an advanced work-flow that handles a specific process were the users are supposed to use a set of document templates through different stages of the process.

What I've done so far is to:
1. Created a folder with a rule that, whenever a folder is being created, copies the documents of interest into the newly created folder.
2. Created a test work-flow that creates a folder in the folder mentioned above (and thus triggering the other script, importing my templates)

3. Now I wish to add these templates as packages to the workflow, but I don't have the noderef. Below is what I've tried, but xpath expressions were apparently deactivated on our Alfresco version.


//Creating a new folder (using comment as the new folder name)
var nodeParent = search.findNode("workspace://SpacesStore/d23c600f-95b1-4edf-adac-3a71ded0f66b");
nodeParent.createFolder(bpm_comment);

//Need to get the noderefs….
var childrens = nodeParent.childrens(bpm_comment+"/innkjøpsmaler");

//Add nodes to the workflow
for (var i = 0; i<childrens.length; i++) {
   bpm_package.addNode(childrens[i].nodeRef);
}


I've tried to find examples that uses the lucene engine(?) instead, but without luck.
Help will be much appreciated!
1 REPLY 1

joakims
Champ in-the-making
Champ in-the-making
Probably not the pretties solution, but this did the trick:

var nodeParent = search.findNode("workspace://SpacesStore/d23c600f-95b1-4edf-adac-3a71ded0f66b");
nodeParent.createFolder(bpm_comment);

var newNode = nodeParent.childByNamePath(bpm_comment);

var spaceTemp = search.findNode("workspace://SpacesStore/4f35ff61-f263-4926-a0cc-a8dcf7616525");
spaceTemp.copy(newNode,true);

var folderNodeMaler = newNode.childByNamePath("Innkjopsmaler");
var firstChildArray = folderNodeMaler.childFileFolders(true, false);

for (var i = 0; i<firstChildArray.length; i++) {
   bpm_package.addNode(firstChildArray[i]);
}