cancel
Showing results for 
Search instead for 
Did you mean: 

Get Category of a document

stoefran
Champ in-the-making
Champ in-the-making
Hello,

I have the following problem. Whenever I move a document into a specific folder I need to find out whether or not the document is linked to a specific category.

I have written the following javascript code to do this, but it does not work and shows the error message "Unknown Exception".


var category = document.properties["cm:categories"];

var approveFolder = space.childByNamePath("tempApprove");

if (approveFolder == null && space.hasPermission("CreateChildren"))
   {
   create the folder for the first time
   approveFolder = space.createFolder("Backup");
   }

var logFile = approveFolder.childByNamePath("logfile.txt");

   if (logFile == null)
   {
      logFile = approveFolder.createFile("logfile.txt");
   }
   if (logFile != null)
   {
      logFile.content += "Datei-Kategorie: " + category[0];
   }

Unfortunately the alfresco debugger is not working either. When i try to start it i get an error aswell.

Can anybody tell me where the error is?
Stoefran
1 REPLY 1

jbarmash
Champ in-the-making
Champ in-the-making
Your code as written does not comment out the line:

    create the folder for the first time

Could that be it?

Also, you might want to check that document has generalclassifiable aspect applied to it, since without it it may not have "cm:categories" property.