<?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 Re: How to recursivly apply an automation chain to a document and to its children (and the children of its children and...) ? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319553#M6554</link>
    <description>&lt;P&gt;To get all the documents in a container (and sub-sub-sub-documents), you can use the &lt;CODE&gt;Query&lt;/CODE&gt; operation to ftech all documents whose &lt;CODE&gt;path&lt;/CODE&gt; starts with the path of the current folder:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Query
    query: SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}'
    language: NXQL
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, you have a list of documents:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If you want to just update some fields, you can directly call &lt;CODE&gt;Document &amp;gt; Update propertty&lt;/CODE&gt; or &lt;CODE&gt;Document &amp;gt; Update Properties&lt;/CODE&gt;. The operation will be applyed for each document in the list&lt;/LI&gt;
&lt;LI&gt;If you want to run a chain, use &lt;CODE&gt; Execution Flow &amp;gt; Run Document Chain&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So, your chain could be...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document
Document &amp;gt; Update Property
    value : myValue
    xpath : mySchema:myProperty
    saved : checked
Fetch &amp;gt; Query
    query: SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}'
    language: NXQL
Document &amp;gt; Update Property
    value : myValue
    xpath : mySchema:myProperty
    saved : checked
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... where all documents will have the "myValue" value in the &lt;CODE&gt;mySchema:myProperty&lt;/CODE&gt; field.&lt;/P&gt;
&lt;P&gt;Or you can use a subchain...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document
Document &amp;gt; Update Property
    value : myValue
    xpath : mySchema:myProperty
    saved : checked
Fetch &amp;gt; Query
    query: SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}'
    language: NXQL
Execution Flow &amp;gt; Run Document Chain
    id: TheSubChain
    isolate: (depends on your needs)
    parameters: (none)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...with &lt;CODE&gt;TheSubChain&lt;/CODE&gt; doing "something". Here, I am just logging an information:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document
Notification &amp;gt; Log
    level: warn
    message: Current doc is doc id @{Document.id}, path: @{Document.path}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;IMPORTANT&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The &lt;CODE&gt;query&lt;/CODE&gt;here gets all and every Nuxeo document, which includes containers (&lt;CODE&gt;Folder&lt;/CODE&gt;, typically), deleted (in the trash), hidden, etc. So, maybe you will want to tune the query. For example, to ignore &lt;CODE&gt;Folder&lt;/CODE&gt; and usually hidden documents:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}' AND ecm:mixinType != 'HiddenInNavigation' AND ecm:isCheckedInVersion = 0 AND ecm:currentLifeCycleState != 'deleted' AND ecm:primaryType != 'Folder'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Thibaud&lt;/P&gt;</description>
    <pubDate>Sun, 06 Apr 2014 18:00:28 GMT</pubDate>
    <dc:creator>ThibArg_</dc:creator>
    <dc:date>2014-04-06T18:00:28Z</dc:date>
    <item>
      <title>How to recursivly apply an automation chain to a document and to its children (and the children of its children and...) ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319551#M6552</link>
      <description>&lt;P&gt;Hi,
I want to modify a property of a document and of all its descendants.&lt;/P&gt;
&lt;P&gt;I have builded an automation chain ("myChain) to make it recursively. This chain is called by an user action.&lt;/P&gt;
&lt;P&gt;It does work only for a document without child...&lt;/P&gt;
&lt;P&gt;Here is the chain :&lt;/P&gt;
&lt;P&gt;Fetch &amp;gt; Context Document(s)&lt;/P&gt;
&lt;P&gt;Document &amp;gt; Update Property
-value : myValue
-xpath : mySchema:myProperty
-saved : checked&lt;/P&gt;
&lt;P&gt;Document &amp;gt; Get Children&lt;/P&gt;
&lt;P&gt;Execution Context &amp;gt; Set Context Variable From Input
-name : myList&lt;/P&gt;
&lt;P&gt;Execution Flow &amp;gt; Run For Each
-id : myChain
-list : myList
-isolate : checked
-item : item&lt;/P&gt;
&lt;P&gt;Can somebody help me ?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2014 17:30:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319551#M6552</guid>
      <dc:creator>jour_</dc:creator>
      <dc:date>2014-04-01T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursivly apply an automation chain to a document and to its children (and the children of its children and...) ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319552#M6553</link>
      <description>&lt;P&gt;Here is the error message I obtain&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2014 10:06:27 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319552#M6553</guid>
      <dc:creator>jour_</dc:creator>
      <dc:date>2014-04-02T10:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursivly apply an automation chain to a document and to its children (and the children of its children and...) ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319553#M6554</link>
      <description>&lt;P&gt;To get all the documents in a container (and sub-sub-sub-documents), you can use the &lt;CODE&gt;Query&lt;/CODE&gt; operation to ftech all documents whose &lt;CODE&gt;path&lt;/CODE&gt; starts with the path of the current folder:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Query
    query: SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}'
    language: NXQL
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then, you have a list of documents:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;If you want to just update some fields, you can directly call &lt;CODE&gt;Document &amp;gt; Update propertty&lt;/CODE&gt; or &lt;CODE&gt;Document &amp;gt; Update Properties&lt;/CODE&gt;. The operation will be applyed for each document in the list&lt;/LI&gt;
&lt;LI&gt;If you want to run a chain, use &lt;CODE&gt; Execution Flow &amp;gt; Run Document Chain&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So, your chain could be...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document
Document &amp;gt; Update Property
    value : myValue
    xpath : mySchema:myProperty
    saved : checked
Fetch &amp;gt; Query
    query: SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}'
    language: NXQL
Document &amp;gt; Update Property
    value : myValue
    xpath : mySchema:myProperty
    saved : checked
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... where all documents will have the "myValue" value in the &lt;CODE&gt;mySchema:myProperty&lt;/CODE&gt; field.&lt;/P&gt;
&lt;P&gt;Or you can use a subchain...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document
Document &amp;gt; Update Property
    value : myValue
    xpath : mySchema:myProperty
    saved : checked
Fetch &amp;gt; Query
    query: SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}'
    language: NXQL
Execution Flow &amp;gt; Run Document Chain
    id: TheSubChain
    isolate: (depends on your needs)
    parameters: (none)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;...with &lt;CODE&gt;TheSubChain&lt;/CODE&gt; doing "something". Here, I am just logging an information:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Fetch &amp;gt; Context Document
Notification &amp;gt; Log
    level: warn
    message: Current doc is doc id @{Document.id}, path: @{Document.path}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;IMPORTANT&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The &lt;CODE&gt;query&lt;/CODE&gt;here gets all and every Nuxeo document, which includes containers (&lt;CODE&gt;Folder&lt;/CODE&gt;, typically), deleted (in the trash), hidden, etc. So, maybe you will want to tune the query. For example, to ignore &lt;CODE&gt;Folder&lt;/CODE&gt; and usually hidden documents:&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;SELECT * FROM Document WHERE dcm:path STARTSWITH '@{Document.path}' AND ecm:mixinType != 'HiddenInNavigation' AND ecm:isCheckedInVersion = 0 AND ecm:currentLifeCycleState != 'deleted' AND ecm:primaryType != 'Folder'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;Thibaud&lt;/P&gt;</description>
      <pubDate>Sun, 06 Apr 2014 18:00:28 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319553#M6554</guid>
      <dc:creator>ThibArg_</dc:creator>
      <dc:date>2014-04-06T18:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to recursivly apply an automation chain to a document and to its children (and the children of its children and...) ?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319554#M6555</link>
      <description>&lt;P&gt;Thank you very much !&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 16:50:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/how-to-recursivly-apply-an-automation-chain-to-a-document-and-to/m-p/319554#M6555</guid>
      <dc:creator>jour_</dc:creator>
      <dc:date>2014-04-08T16:50:01Z</dc:date>
    </item>
  </channel>
</rss>

