AnsweredAssumed Answered

Problem executing thumbnail example

Question asked by kamlesh on May 29, 2009
Latest reply on Jun 2, 2009 by mikeh

I am completely new to Alfresco JavaScript APIs and WebScripts. I have downloaded the thumbnail's example source code from Jeff's blog []. It uses two scripts one to upload a file and create thumbnail and other to fetch the thumbnail. Following are the scripts:

for each (field in formdata.fields) {
   if ( == "file" && field.isFile) {
      filename = field.filename;
      content = field.content;
      mimetype = field.mimetype;
var results = search.luceneSearch("+PATH:\"app:company_home/cm:Someco/cm:Images\"");
var targetFolder = results[0];
var newDoc = targetFolder.createFile(filename); //line A
//var newDoc = companyhome.createFile(filename);//line B; = mimetype;;

// if we know we will always want a thumbnail for this object
// we could request that it be created here or we can do it later
newDoc.createThumbnail("scImageThumbnail", true);//line C


var results = search.luceneSearch("+PATH:\"app:company_home/cm:Someco/cm:Images\"");
var targetFolder = results[0];
model.images = targetFolder.children;//line D
//model.images = companyhome.children;//line E

Now, the problem is when I run the above script target folder comes as null and hence the script results in an exception. When I comment line A and run the script with line B uncommented, it works and uploads the file in company home folder. So here is the problem with the lucene query and it is not returning me the values. But where has the cm:Images come from in the example I am unable to figure out. Also though the code at line C is not giving any exception neither it is generating any thumbnail as a child node of the document uploaded. What could be the reason?

Now with line B uncommented in first js, I commented line D in imagelist.js and uncommented line E. But this time the javascript is throwing an exception saying 'companyhome' is undefined. So i guess there is some problem with the scope of the companyhome variable. can you please tell me how can I modify the imagelist.js to make my code working.

Any help will be appreciated,
- Kamlesh