cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot add custom property to document

edazcalf
Champ in-the-making
Champ in-the-making
Hello.
How can I add custom properties to documents in my repository?

I followed the example in the alfresco wiki:
http://wiki.alfresco.com/wiki/3.2_JavaScript_API#Modifying_and_Creating_API
… but when I try to access upload.properties["myCustomProperty0"] from the response template I get an error:
11020015 Error during processing of the template 'Expression upload.properties["myCustomProperty0"] is undefined

This is part of the code in my js file (upload.post.js):
 
//…
// create document in company home for uploaded file
  upload = companyhome.createFile("BAupload" + companyhome.children.length + "_" + filename) ;
  upload.properties.content.write(content);
  upload.properties.content.mimetype = "UTF-8";
  upload.properties.title = title;
  upload.properties.description = description;
  upload.properties["myCustomProperty0"] = "custompropertyValue";
  upload.save();
 
  // setup model for response template
  model.upload = upload;


Thanks!!
1 REPLY 1

edazcalf
Champ in-the-making
Champ in-the-making
Solved.
My custom property was successfully updated, but I had to remove and then add the script in order to have the server take the changes made to the js file. Refreshing web script list was not enough.