AnsweredAssumed Answered

problem with webscript to update a document

Question asked by geveritt on Jan 3, 2008
Latest reply on Oct 12, 2011 by sanket
I am new to Alfresco and I am using Alfresco version 2.9.0B.  I have made some changes to the google gadgets

update.post.js as below…  The problem is when it attempts to execute the statement

document.properties.content.write(content);

I get an error org.mozilla.javascript.EvaluatorException: Can't find method org.alfresco.repo.jscript.ScriptNode$ScriptContentData.write(string) (AlfrescoScript#19)
which is the line with the …content.write(content).  The node contains HTML text and the content variable contains HTML text.

The search.findNode seems to work and setting the encoding seems to work.  If I comment out the …content.write(content) the document.save() seems to work.

I'm not sure how to fix this problem.  Any help would be appreciated.

Thanks
Glenn E.


//Code below
var content = args["content"];
var id = args["id"];


// ensure mandatory file attributes have been located
if (content == null)
{
   status.code = 400;
   status.message = "Uploaded file cannot be located in request.";
   status.redirect = true;
}
else
{
   // update document with uploaded content
   var document = search.findNode("workspace://SpacesStore/" + id);
   if (document != null)
   {
      document.properties.content.encoding = "UTF-8";
      document.properties.content.write(content);
      document.save();
     
      // setup model for response template
      model.document = document;
   }
   else
   {
      status.code = 400;
      status.message = "Error: File for update does not exist";
      status.redirect = true;
   }
}

Outcomes