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.
Hi,
after doc.content=... add the line
doc.save();
Then you should see your doc in userhome.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.