cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript error

mattew80
Champ in-the-making
Champ in-the-making
Hi.
in the first place I must excuse me for my very bad english…but I'm an italian boy Smiley Happy
I'm studing from the "Alfresco Enterprise Content Management Implementation" book and I want to create a business rule with the follow custom script :

var stagingFolder       = companyhome.childByNamePath("Intranet/Marketing Communications/Website Documents/Staging");
var productionFolder = companyhome.childByNamePath("Intranet/Marketing Communications/Website Documents/Production");

if(stagingFolder != null)
{
   var i=0;
   var today = new Date();
   stagingChildren = stagingFolder.children;
   stagingTotal = stagingChildren.length;
   for(i=0; i<stagingTotal;i++)
   {
      child = stagingChildren[i];
      if(child.properties["cm:from"] <= today)
      {
         child.move(productionFolder);
      }
   }
}

but don't work…probably becouse the Alfresco version of book is 1.4 and I use the 2.1 version.
Any suggestions?

Best regards and thanks for attention,
Matteo
3 REPLIES 3

xerox
Champ in-the-making
Champ in-the-making
Do you get an error?

p.s. try to replace the blanks in your childbynamepath with "_x0020_"

e.g.:var stagingFolder       = companyhome.childByNamePath("Intranet/Marketing_x0020_Communications/Website_x0020_Documents/Staging");

mattew80
Champ in-the-making
Champ in-the-making
I'm just do it…but don't work.
There's not an error…simply don't do anything Smiley Sad
I've try an example script of Wiki Guide for Alfresco 2.0 and is all ok.
There's a log that I can see for information? In the dos shell don't gimme nobody information or error.

Thanks
Matteo

kevinr
Star Contributor
Star Contributor
p.s. try to replace the blanks in your childbynamepath with "_x0020_"

e.g.:var stagingFolder       = companyhome.childByNamePath("Intranet/Marketing_x0020_Communications/Website_x0020_Documents/Staging");

The childByNamePath() method does not require encoding of characters - it uses the 'cm:name' matches directly.

mattew80:
You say it just doesn't work - but do those folders exist on your system? If not make sure they are created exactly as typed.

Kevin