<?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 Condition in an automation chain in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322105#M9106</link>
    <description>&lt;P&gt;Hi,
How can I use some sort of conditional statement in the automation chain?
I want to create a document under the private workspace of an user only if it wasn't created before.&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 07 Oct 2011 15:40:54 GMT</pubDate>
    <dc:creator>elteo_</dc:creator>
    <dc:date>2011-10-07T15:40:54Z</dc:date>
    <item>
      <title>Condition in an automation chain</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322105#M9106</link>
      <description>&lt;P&gt;Hi,
How can I use some sort of conditional statement in the automation chain?
I want to create a document under the private workspace of an user only if it wasn't created before.&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2011 15:40:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322105#M9106</guid>
      <dc:creator>elteo_</dc:creator>
      <dc:date>2011-10-07T15:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Condition in an automation chain</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322106#M9107</link>
      <description>&lt;P&gt;Assuming you are doing that in Nuxeo-Studio:&lt;/P&gt;
&lt;P&gt;Start by creating 2 operations:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;The first of type: "Document &amp;gt; Create", let's call it &lt;CODE&gt;CREATE_MY_DOC&lt;/CODE&gt;.
You could supply here a document path as a parameter of your expected/existing document.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;The second of type: "User Interface &amp;gt; Add Info Message", let's call it &lt;CODE&gt;NOTIFY_DOCUMENT_EXISTS&lt;/CODE&gt;.
This is just an example, you could use a void operation instead.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Then create your "logic" operation of type: "Execution Flow &amp;gt; Run Operation"&lt;/P&gt;
&lt;P&gt;Give this operation an ID of the following form: &lt;CODE&gt;(condition?op1:op2)&lt;/CODE&gt; where if the "condition" is true, then "op1" is executed, otherwise "op2"&lt;/P&gt;
&lt;P&gt;In the condition statement you can check if your document exists, for instance using NXQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@{(Session.query("SELECT * FROM Document WHERE ecm:path='MY_PATH").size()==0?"CREATE_MY_DOC":"NOTIFY_DOCUMENT_EXISTS")}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This should launch the appropriate operation creating the document if, and only if, it does not yet exist.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Oct 2011 22:34:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322106#M9107</guid>
      <dc:creator>Wojciech_Sulejm</dc:creator>
      <dc:date>2011-10-07T22:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Condition in an automation chain</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322107#M9108</link>
      <description>&lt;P&gt;Using "Execution Flow &amp;gt; Run Operation" is the key. But to avoid limits of using ternary operator which enables you to choose among only two different behaviors, you can actually "compute" the name of the operation chain to execute in a  previous "Run Script" operation, storing the result in a context variable and referencing it in the "ID" parameter of Run Operation.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2011 02:29:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/condition-in-an-automation-chain/m-p/322107#M9108</guid>
      <dc:creator>Alain_ESCAFFRE</dc:creator>
      <dc:date>2011-12-14T02:29:50Z</dc:date>
    </item>
  </channel>
</rss>

