<?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 execute a script only for a special filename in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/execute-a-script-only-for-a-special-filename/m-p/279219#M232349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i am trying to mogrify uploaded pictures to a fixed size.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;so i found here an appropriate Javascript here&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://forums.alfresco.com/forum/developer-discussions/alfresco-explorer-development/overwrite-files-scripts-08012008-1547" rel="nofollow noopener noreferrer"&gt;https://forums.alfresco.com/forum/developer-discussions/alfresco-explorer-development/overwrite-files-scripts-08012008-1547&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;I created a rule, which execute the script when a jpeg get uploaded, which&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is not optimal, cause this runs in an endless loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now i tried to check the documentname in the script if it contains or&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;starts with resized_.. but no solution as described here - &lt;/SPAN&gt;&lt;A href="https://forums.alfresco.com/forum/developer-discussions/other-apis/string-operations-alfresco-scripts-03232012-1135" rel="nofollow noopener noreferrer"&gt;https://forums.alfresco.com/forum/developer-discussions/other-apis/string-operations-alfresco-scripts-03232012-1135&lt;/A&gt;&lt;SPAN&gt; -&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; worked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could some hint me to the correct syntax for the if clause?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The currect Script looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var strOrigName = document.properties.name;&lt;BR /&gt;var jstrOrigName = new java.lang.String(document.properties.name);&lt;BR /&gt;&lt;BR /&gt;if (!jstrOrigName.contains("resized_")) {&lt;BR /&gt; var tmpName = "resized_" + document.properties.name;&lt;BR /&gt; document.properties.name = tmpName;&lt;BR /&gt; var rImage=document.transformImage("image/jpeg","-normalize -resize&lt;BR /&gt; 1024x768", document.parent);&lt;BR /&gt; if (rImage){&lt;BR /&gt;&amp;nbsp; document.properties.name = strOrigName;&lt;BR /&gt;&amp;nbsp; document.save();&lt;BR /&gt;&amp;nbsp; document.remove();&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This are some tests i made as described here&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://forums.alfresco.com/forum/developer-discussions/other-apis/string-operations-alfresco-scripts-03232012-1135" rel="nofollow noopener noreferrer"&gt;https://forums.alfresco.com/forum/developer-discussions/other-apis/string-operations-alfresco-scripts-03232012-1135&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var jstrOrigName = new java.lang.String(document.properties.name);&lt;BR /&gt;if (!jstrOrigName.contains("resized_")) {&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;catalina.out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "java" is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var jSstrOrigName = new String(document.properties.name);&lt;BR /&gt;if (!jSstrOrigName.contains("resized_")){&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;catalina.out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;no function resize&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;if (strOrigName.indexOf("resized_") != -1){&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;no error, no resize&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;best regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thomas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Dec 2015 09:53:43 GMT</pubDate>
    <dc:creator>stegbth</dc:creator>
    <dc:date>2015-12-23T09:53:43Z</dc:date>
    <item>
      <title>execute a script only for a special filename</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/execute-a-script-only-for-a-special-filename/m-p/279219#M232349</link>
      <description>Hi,i am trying to mogrify uploaded pictures to a fixed size.so i found here an appropriate Javascript herehttps://forums.alfresco.com/forum/developer-discussions/alfresco-explorer-development/overwrite-files-scripts-08012008-1547I created a rule, which execute the script when a jpeg get uploaded, wh</description>
      <pubDate>Wed, 23 Dec 2015 09:53:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/execute-a-script-only-for-a-special-filename/m-p/279219#M232349</guid>
      <dc:creator>stegbth</dc:creator>
      <dc:date>2015-12-23T09:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: execute a script only for a special filename</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/execute-a-script-only-for-a-special-filename/m-p/279220#M232350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use alfresco OOB condition while applying rule to execute js.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Select conditions –&amp;gt; Name contains value – add your file name text pattern.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So you will not need to make this name check in your js.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hope this helps!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 06:33:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/execute-a-script-only-for-a-special-filename/m-p/279220#M232350</guid>
      <dc:creator>niketapatel</dc:creator>
      <dc:date>2016-01-20T06:33:15Z</dc:date>
    </item>
  </channel>
</rss>

