<?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 to seach in a specific space in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180574#M133704</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm makin a script to get all the objects in a specific space (called "Aprobados") where the created or last modified date is today. And I also want to get all metadata from the searchrd objects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can anyone help me please?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me explain you the process I need to execute&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Search for all the pdf documents of a given space called "Aprobados" which have been modified "today".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) I need to create a txt file with all the metadata of all of those modified pdf documents stored in this space that matched this search criteria.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Place the txt file in a given space so another process can get it by FTP&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the code I have written, however I am not very sure of the search funcion, as I need to search in the "Aprobados" space but also inside its child nodes recursively.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you please take a look to my code and let me know if you think it is ok?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will really appreciate it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;// We create the folder to place the txt file&lt;BR /&gt;var subir = space.childByNamePath("Subir Facturas");&lt;BR /&gt;var recoger = subir.childByNamePath("Recoger");&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// If there is already a txt file we must delete it&lt;BR /&gt;for each (var doc in recoger.children) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (doc.mimetype == "text/plain");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; doc.remove();&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// Get the path to the parent space where to look for the files&lt;BR /&gt;var revision = space.childByNamePath("Revisar");&lt;BR /&gt;var aprobados = revision.childByNamePath("Aprobadas");&lt;BR /&gt;var today = new Date();&lt;BR /&gt;var ano = today.getFullYear();&lt;BR /&gt;var buscarAno = aprobados.childByNamePath(ano);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;// Now we firstly create the txt file&lt;BR /&gt;//String fecha = today.getDate() + "-" + today.getMonth() +1 + "-" + today.getFullYear();&lt;BR /&gt;file = recoger.createFile("metadatos_facturas.txt");&lt;BR /&gt;&lt;BR /&gt;// We run the search for all the pdf files that have been modified today in the&lt;BR /&gt;// space of the current year&lt;BR /&gt;var docs = search.xpathSearch([cm:modified]=today,buscarAno);&lt;BR /&gt;&lt;BR /&gt;// For each doc found matching the search clause we must write their metadata in the&lt;BR /&gt;// txt file - one row with metadata per file found&lt;BR /&gt;&lt;BR /&gt;for each (docs) {&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (docs!=null &amp;amp;&amp;amp; docs.mimetype == "application/pdf")&lt;BR /&gt;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workingcopy=file.checkout();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workingcopy.content = "|"+docs.name+"|"+docs.start_date+"|"+docs.Private_Id+"|=";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file = workingcopy.checkin();&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&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;/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;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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Apr 2014 15:34:24 GMT</pubDate>
    <dc:creator>cperez</dc:creator>
    <dc:date>2014-04-02T15:34:24Z</dc:date>
    <item>
      <title>script to seach in a specific space</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180574#M133704</link>
      <description>I'm makin a script to get all the objects in a specific space (called "Aprobados") where the created or last modified date is today. And I also want to get all metadata from the searchrd objects.Can anyone help me please?Let me explain you the process I need to execute1) Search for all the pdf docum</description>
      <pubDate>Wed, 02 Apr 2014 15:34:24 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180574#M133704</guid>
      <dc:creator>cperez</dc:creator>
      <dc:date>2014-04-02T15:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: script to seach in a specific space</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180575#M133705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi cperez,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The best way to do this is to use lucene or xpath search, because it allows you to search recursively in the child nodes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It should be something like this using lucene search:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp; var docs = search.luceneSearch("PATH:'app:company_home/cm:Revisar/cm:Aprobados//.' AND&amp;nbsp; @cm\\:modified:[NOW TO MAX]");&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;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here you have more information about range queries:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://wiki.alfresco.com/wiki/Search#Range_Queries" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/Search#Range_Queries&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.alfresco.com/forum/developer-discussions/web-scripts/lucene-search-date-range-created-modified-not-working" rel="nofollow noopener noreferrer"&gt;http://forums.alfresco.com/forum/developer-discussions/web-scripts/lucene-search-date-range-created-modified-not-working&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://forums.alfresco.com/forum/developer-discussions/repository-services/attributes-lucene-date-range-10122007-1524" rel="nofollow noopener noreferrer"&gt;https://forums.alfresco.com/forum/developer-discussions/repository-services/attributes-lucene-date-range-10122007-1524&lt;/A&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2014 10:50:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180575#M133705</guid>
      <dc:creator>cybermakoki</dc:creator>
      <dc:date>2014-04-03T10:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: script to seach in a specific space</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180576#M133706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi cybermakoki,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I got.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed the search and I use the luceneSearch like you said.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I use the dinamic path from a specific folder instead of a static path, the range date search to get all the documents today, and I also search only pdf documents.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the code that I use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var sdate=today.getFullYear()+"\-"+(today.getMonth()+1)+"\-"+today.getDate() + "T00:00:00";&lt;BR /&gt;var tdate=today.getFullYear()+"\-"+(today.getMonth()+1)+"\-"+(today.getDate()+1) + "T00:00:00";&lt;BR /&gt;var spath="'+PATH:\""+aprobados.displayPath +"//*\" + ";&lt;BR /&gt;var scontent="@\\{http\\://&lt;A href="http://www.alfresco.org/model/content/1.0\\}content.mimetype:application/pdf" rel="nofollow noopener noreferrer"&gt;www.alfresco.org/model/content/1.0\\}content.mimetype:application/pdf&lt;/A&gt; + ";&lt;BR /&gt;var qdate="@cm\\:modified:[" + sdate + " TO " + tdate +"]'";&lt;BR /&gt;var strq=spath+scontent+qdate;&lt;BR /&gt;&lt;BR /&gt;// Do the search and save the vales&lt;BR /&gt;var nodes=search.luceneSearch(strq);&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;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you so much.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2014 11:27:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180576#M133706</guid>
      <dc:creator>cperez</dc:creator>
      <dc:date>2014-04-03T11:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: script to seach in a specific space</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180577#M133707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's perfect!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm glad I helped you &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2014 11:44:20 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/script-to-seach-in-a-specific-space/m-p/180577#M133707</guid>
      <dc:creator>cybermakoki</dc:creator>
      <dc:date>2014-04-03T11:44:20Z</dc:date>
    </item>
  </channel>
</rss>

