<?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: Why this error occurs in automation chain when use Query operation? in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324300#M11301</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;The reason of your problem is that create Relation expects a Document as a value for parameter "Object", and you give a document list (tramiteFolder).&lt;/P&gt;
&lt;P&gt;Indeed, the input of the chain is a document list. So, Context.SetInputAsVar sets a documents list as a variable.&lt;/P&gt;
&lt;P&gt;You could simply refer to "@{workflowDocuments[0]}"  in the object attribute,   or, just before Context.SetInputAsVar, use a Run Script operation with "return This[0]"  script value.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2013 01:22:46 GMT</pubDate>
    <dc:creator>Alain_ESCAFFRE</dc:creator>
    <dc:date>2013-07-10T01:22:46Z</dc:date>
    <item>
      <title>Why this error occurs in automation chain when use Query operation?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324297#M11298</link>
      <description>&lt;P&gt;I have a content view and it has defined a nxql query, it works perfectly. Now I want to get those documents using query operation  in a automation chain for create relations with another documents but an error is printed in the server log.&lt;/P&gt;
&lt;P&gt;My automation chain:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;gt; Context.FetchDocument:run

&amp;gt; Context.SetInputAsVar:run
name: tramiteFolder

&amp;gt; Context.SetVar:run
name: variableContext
value: @{Document["myschema:myfield"]}

&amp;gt; Document.Query:run
query: SELECT * FROM Document WHERE anotherschema:anotherfield = '@{variableContext}' AND ecm:currentLifeCycleState != 'deleted'

&amp;gt; Relations.CreateRelation:run
object: @{Context["tramiteFolder"]}
predicate: &lt;A href="http://purl.org/dc/terms/References" target="test_blank"&gt;http://purl.org/dc/terms/References&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is my logic:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I have a workflow, it is started automaticaly when document type "A" is created&lt;/LI&gt;
&lt;LI&gt;I want to run my chain on automatic_transition from start node.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;the error printed in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Caused by: org.nuxeo.ecm.core.api.ClientRuntimeException: org.nuxeo.ecm.platform.routing.api.exception.DocumentRouteException: Error running chain: test
	at org.nuxeo.ecm.platform.routing.core.impl.GraphRunner.run(GraphRunner.java:81)
	at org.nuxeo.ecm.platform.routing.core.impl.DocumentRouteElementImpl.run(DocumentRouteElementImpl.java:82)
	at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingEngineServiceImpl.start(DocumentRoutingEngineServiceImpl.java:37)
	at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingServiceImpl$1.run(DocumentRoutingServiceImpl.java:194)
	at org.nuxeo.ecm.core.api.UnrestrictedSessionRunner.runUnrestricted(UnrestrictedSessionRunner.java:115)
	at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingServiceImpl.createNewInstance(DocumentRoutingServiceImpl.java:164)
	at org.nuxeo.ecm.platform.routing.core.impl.DocumentRoutingServiceImpl.createNewInstance(DocumentRoutingServiceImpl.java:230)
	at org.nuxeo.ecm.platform.routing.api.operation.StartWorkflowOperation.startNewInstance(StartWorkflowOperation.java:76)
	at org.nuxeo.ecm.platform.routing.api.operation.StartWorkflowOperation.run(StartWorkflowOperation.java:71)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:125)
	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:132)
	... 141 more
Caused by: org.nuxeo.ecm.platform.routing.api.exception.DocumentRouteException: Error running chain: test
	at org.nuxeo.ecm.platform.routing.core.impl.GraphNodeImpl.executeChain(GraphNodeImpl.java:470)
	at org.nuxeo.ecm.platform.routing.core.impl.GraphNodeImpl.executeTransitionChain(GraphNodeImpl.java:444)
	at org.nuxeo.ecm.platform.routing.core.impl.GraphRunner.runGraph(GraphRunner.java:270)
	at org.nuxeo.ecm.platform.routing.core.impl.GraphRunner.run(GraphRunner.java:75)
	... 155 more
Caused by: org.nuxeo.ecm.automation.AdapterNotFoundException: No type adapter found for input: class org.nuxeo.ecm.core.api.impl.DocumentModelListImpl and output interface org.nuxeo.ecm.core.api.DocumentModel
&amp;gt; Context.FetchDocument:run
&amp;gt; Context.SetInputAsVar:run
&amp;gt; Context.SetVar:run
&amp;gt; Document.Query:run
&amp;gt; Relations.CreateRelation:run
	at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.getAdaptedValue(OperationServiceImpl.java:244)
	at org.nuxeo.ecm.automation.core.impl.OperationTypeImpl.inject(OperationTypeImpl.java:179)
	at org.nuxeo.ecm.automation.core.impl.OperationTypeImpl.newInstance(OperationTypeImpl.java:155)
	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.doInvoke(InvokableMethod.java:114)
	at org.nuxeo.ecm.automation.core.impl.InvokableIteratorMethod.doInvoke(InvokableIteratorMethod.java:111)
	at org.nuxeo.ecm.automation.core.impl.InvokableMethod.invoke(InvokableMethod.java:132)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:114)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.doInvoke(CompiledChainImpl.java:117)
	at org.nuxeo.ecm.automation.core.impl.CompiledChainImpl.invoke(CompiledChainImpl.java:96)
	at org.nuxeo.ecm.automation.core.impl.OperationServiceImpl.run(OperationServiceImpl.java:65)
	at org.nuxeo.ecm.platform.routing.core.impl.GraphNodeImpl.executeChain(GraphNodeImpl.java:462)
	... 158 more
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;on the other hand, I have another chain where I create this same logic and works perfectly  but with another query:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;SELECT * FROM MyTypeDocument WHERE uid:uid = '@{variableContext}'
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 May 2013 22:42:53 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324297#M11298</guid>
      <dc:creator>geekonspace</dc:creator>
      <dc:date>2013-05-16T22:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why this error occurs in automation chain when use Query operation?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324298#M11299</link>
      <description>&lt;P&gt;Why are you using @{code} in the query ? Are you using the context object.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2013 09:16:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324298#M11299</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2013-05-21T09:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Why this error occurs in automation chain when use Query operation?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324299#M11300</link>
      <description>&lt;P&gt;Hi, I updated my example code in my question, "code" is a context variable. I replaced "code" by variableContext. But is strange because the operation create relations should accept documentModelList. My nuxeo instance is 5.6 and hotfixs from 1 to 16&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2013 15:12:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324299#M11300</guid>
      <dc:creator>geekonspace</dc:creator>
      <dc:date>2013-05-21T15:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Why this error occurs in automation chain when use Query operation?</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324300#M11301</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;The reason of your problem is that create Relation expects a Document as a value for parameter "Object", and you give a document list (tramiteFolder).&lt;/P&gt;
&lt;P&gt;Indeed, the input of the chain is a document list. So, Context.SetInputAsVar sets a documents list as a variable.&lt;/P&gt;
&lt;P&gt;You could simply refer to "@{workflowDocuments[0]}"  in the object attribute,   or, just before Context.SetInputAsVar, use a Run Script operation with "return This[0]"  script value.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2013 01:22:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/why-this-error-occurs-in-automation-chain-when-use-query/m-p/324300#M11301</guid>
      <dc:creator>Alain_ESCAFFRE</dc:creator>
      <dc:date>2013-07-10T01:22:46Z</dc:date>
    </item>
  </channel>
</rss>

