<?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 script in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/script/m-p/66142#M22308</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have made a script to set the document type depending of word of their name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (document.parent.hasAspect("pp:freightFolder")) {&lt;BR /&gt; var file = document.name;&lt;BR /&gt; var dict = new Object();&lt;BR /&gt; document.addAspect('pp:document');&lt;BR /&gt; document.properties["pp:refBlNumber"] = document.parent.properties['pp:bl_number'];&lt;BR /&gt; document.properties["pp:refHblNumber"] = document.parent.name.slice(1);&lt;BR /&gt; document.properties["pp:refContainers"]=document.parent.properties['pp:containers'];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dict = {&lt;BR /&gt; "Proform Invoice":"PIN",&lt;BR /&gt; "PI":"Proform Invoice",&lt;BR /&gt; "PIN":"Proform Invoice",&lt;BR /&gt; "Invoice":"Invoice",&lt;BR /&gt; "INV":"Invoice",&lt;BR /&gt; "Packing List":"Packing List", &lt;BR /&gt; "PKL":"Packing List",&lt;BR /&gt; "PKG":"Packing List",&lt;BR /&gt; "Packing List Cropped":"Packing List Cropped",&lt;BR /&gt; "Cropped":"Packing List Cropped",&lt;BR /&gt; "PKC":"Packing List Cropped",&lt;BR /&gt; "Invoice &amp;amp; Packing List":"Invoice &amp;amp; Packing List",&lt;BR /&gt; "IPK":"Invoice &amp;amp; Packing List",&lt;BR /&gt; "Booking":"Booking",&lt;BR /&gt; "BKG":"Booking",&lt;BR /&gt; "ISF":"ISF",&lt;BR /&gt; "Arrival Notice":"Arrival Notice",&lt;BR /&gt; "ARN":"Arrival Notice",&lt;BR /&gt; "Freight Invoice":"Freight Invoice",&lt;BR /&gt; "FIN":"Freight Invoice",&lt;BR /&gt; "Bill of Lading":"Bill of Lading",&lt;BR /&gt; "BOL":"Bill of Lading",&lt;BR /&gt; "Telex Release":"Telex Release",&lt;BR /&gt; "TXR":"Telex Release",&lt;BR /&gt; "Release":"Telex Release",&lt;BR /&gt; "Custom Entry":"Custom Entry",&lt;BR /&gt; "Custom":"Custom Entry", &lt;BR /&gt; "Entry":"Custom Entry",&lt;BR /&gt; "All Docs":"All Docs",&lt;BR /&gt; "ALL":"All Docs"&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; for(var key in dict) { &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (file.toLowerCase().search(key.toLowerCase()) != -1) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;document.properties["pp:docType"] = dict[key];&lt;/STRONG&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (dict[key] == "Packing List" || dict[key] == "Packing List Cropped"){&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;document.addAspect('pp&lt;img id="smileytongue" class="emoticon emoticon-smileytongue" src="https://connect.hyland.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;ackingRefNumber');&lt;/STRONG&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (dict[key] == "Invoice" || dict[key] == "Invoice &amp;amp; Packing List" || dict[key] == "Freight Invoice") {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;document.specializeType('pp:Invoice');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt; }&lt;BR /&gt; document.save();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can see, in this script I assign to some docs the type "&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;invoice&lt;/STRONG&gt;&lt;/SPAN&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This Invoice type has a property called &lt;STRONG&gt;invoiceStatus&lt;/STRONG&gt; with a DEFAULT VALUE: "&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;Not Processed&lt;/STRONG&gt;&lt;/SPAN&gt;".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Ok, knowing this, here come the problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also have a smart folder, with this query: &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;"query": "=pp:invoice_status:'Not Processed' and =pp:docType:'Invoice'"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;When I add a file with a string invoice inside its name, it change its name and assign the type invoice to the file, and i suppose the default value with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But when I go to the smart folder to check if the file is in it. It doesn't!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to go to the file, open its properties (all properties are there) and just save the file (without modifying nothing). Then I can go to the smart folder and there it is!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;It seems that when I assign a property to a document using a script it does not really assign the default value.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;I made a second test:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create a simple rule, where: if a document is create and its a type is "content", and the name begins with invoice, then assign specilizetype "invoice".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I drag and drop a file with name begining with Invoice, the rule assigns it the typ invoice, and it assigns the default value &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;pp:invoice_status:'Not Processed', &lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;and then when I go to the smart folder it appears.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;My conclusion is that when we use a script, default values are not being assigned. Some one can confirm me that? Or there is a real problem here?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Nov 2018 14:28:01 GMT</pubDate>
    <dc:creator>chavezdf</dc:creator>
    <dc:date>2018-11-09T14:28:01Z</dc:date>
    <item>
      <title>script</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/script/m-p/66142#M22308</link>
      <description>I have made a script to set the document type depending of word of their name.if (document.parent.hasAspect("pp:freightFolder")) { var file = document.name; var dict = new Object(); document.addAspect('pp:document'); document.properties["pp:refBlNumber"] = document.parent.properties['pp:bl_number'];</description>
      <pubDate>Fri, 09 Nov 2018 14:28:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/script/m-p/66142#M22308</guid>
      <dc:creator>chavezdf</dc:creator>
      <dc:date>2018-11-09T14:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: script</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/script/m-p/66143#M22309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After you drop a doc into your folder to trigger the rule, and before you edit the document, have you gone into the node browser to inspect the value of pp:invoice_status? I think it might be instructive.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2018 20:40:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/script/m-p/66143#M22309</guid>
      <dc:creator>jpotts</dc:creator>
      <dc:date>2018-11-09T20:40:31Z</dc:date>
    </item>
  </channel>
</rss>

