AnsweredAssumed Answered

Error creating file through webscript

Question asked by pat9rv3sousa on May 22, 2017
Latest reply on May 22, 2017 by mehe

I'm trying to create a file if it doesn't exists or modified it if it exists.

I created a webscript:

> createfile.get.js

function main()

{
var doc = userhome.childByNamePath('answers.txt');
if (!doc)
{
doc = userhome.createFile("answers.txt");
doc.addAspect("cm:versionable");
doc.content = 'Questionnaire';

var trans1 = doc.transformDocument('application/pdf');
}
else {
var workingCopy = doc.checkout();
workingCopy.content = 'Questionnaire modified';

// check it in
doc = workingCopy.checkin();
}
model.doc=doc;


}

main();


However, if I don't have the file in my home, this doesn't create the new file. If I create manually the file "answers.txt" in Alfresco, it modifies the content. Any reason for this?

In catalina.out or in the debugger in the browser, I don't get any information of any error.

Thanks.

Outcomes