<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error creating file through webscript in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/error-creating-file-through-webscript/m-p/17232#M7637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a file if it doesn't exists or modified it if it exists.&lt;/P&gt;&lt;P&gt;I created a webscript:&lt;/P&gt;&lt;P&gt;&amp;gt; createfile.get.js&lt;/P&gt;&lt;P&gt;function main()&lt;BR /&gt; &lt;BR /&gt; {&lt;BR /&gt; var doc = userhome.childByNamePath('answers.txt');&lt;BR /&gt; if (!doc)&lt;BR /&gt; {&lt;BR /&gt; doc = userhome.createFile("answers.txt");&lt;BR /&gt; doc.addAspect("cm:versionable");&lt;BR /&gt; doc.content = 'Questionnaire';&lt;BR /&gt; &lt;BR /&gt; var trans1 = doc.transformDocument('application/pdf');&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; var workingCopy = doc.checkout();&lt;BR /&gt; workingCopy.content = 'Questionnaire modified';&lt;BR /&gt; &lt;BR /&gt; // check it in &lt;BR /&gt; doc = workingCopy.checkin();&lt;BR /&gt; }&lt;BR /&gt; model.doc=doc;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; main();&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;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?&lt;/P&gt;&lt;P&gt;In catalina.out or in the debugger in the browser, I don't get any information of any error.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 May 2017 17:12:02 GMT</pubDate>
    <dc:creator>pat9rv3sousa</dc:creator>
    <dc:date>2017-05-22T17:12:02Z</dc:date>
    <item>
      <title>Error creating file through webscript</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-creating-file-through-webscript/m-p/17232#M7637</link>
      <description>I'm trying to create a file if it doesn't exists or modified it if it exists.I created a webscript&lt;IMG id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt; createfile.get.jsfunction main()  { var doc = userhome.childByNamePath('answers.txt'); if (!doc) { doc = userhome.createFile("answers.txt"); doc.addAspect("cm:versionable"); doc.content = 'Questio</description>
      <pubDate>Mon, 22 May 2017 17:12:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-creating-file-through-webscript/m-p/17232#M7637</guid>
      <dc:creator>pat9rv3sousa</dc:creator>
      <dc:date>2017-05-22T17:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error creating file through webscript</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/error-creating-file-through-webscript/m-p/17233#M7638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after doc.content=... &amp;nbsp; &amp;nbsp; add the line&lt;/P&gt;&lt;P&gt;doc.save();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you should see your doc in userhome.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 May 2017 18:28:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/error-creating-file-through-webscript/m-p/17233#M7638</guid>
      <dc:creator>mehe</dc:creator>
      <dc:date>2017-05-22T18:28:29Z</dc:date>
    </item>
  </channel>
</rss>

