<?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 Unable to Set Context variables.. in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326423#M13424</link>
    <description>&lt;P&gt;I have an automation chain that&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;gets a value from a document,&lt;/LI&gt;
&lt;LI&gt;sets the context variable,&lt;/LI&gt;
&lt;LI&gt;pushes it onto the stack,&lt;/LI&gt;
&lt;LI&gt;uses nxql to query a document based on the context variable,&lt;/LI&gt;
&lt;LI&gt;sets another context variable with a value from the queried document,&lt;/LI&gt;
&lt;LI&gt;pops the previous document&lt;/LI&gt;
&lt;LI&gt;and then uses all of that to send an email template. (A classic lookup operation)..&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;When I hard code my "values" everything works as expected. When I attempt to set a context variable, it fails.&lt;/P&gt;
&lt;P&gt;The automation chain is as follows:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://connect.hyland.com/upfiles/contextproblemflow_1.jpg" alt="alt text" /&gt;&lt;/P&gt;
&lt;P&gt;Each time I attempt to get a value, it fails with the following entry in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;ERROR [org.nuxeo.ecm.automation.core.events.OperationEventListener] Failed to handle event documentModified using chain: submitFOIAtoAgency
org.nuxeo.ecm.automation.OperationException: Failed to invoke operation Context.SetVar
*and*
Caused by: [Error: org.nuxeo.ecm.core.api.impl.DocumentModelImpl cannot be cast to java.lang.Class]
[Near : {... Unknown ....}]
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The automation chain is being kicked off by a document Create or Edit event handler.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I have further refined my issue:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;during the Fetch-&amp;gt;Query operation I use the context variable as a parameter in my NXQL..&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I can run the query with the expected values and it returns a document&lt;/LI&gt;
&lt;LI&gt;I can run the query with a hard coded parameter and it doesn't fail.&lt;/LI&gt;
&lt;LI&gt;I can run the NXQL with SELECT * FROM Document WHERE GOVAGENCY:agency_id = '+@{Context["agencyid"]}+' and it gives no complaints or failures (I have HAD queries fail before)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The context variable setting fails due to null document (from the Fetch operation I presume)&lt;/P&gt;
&lt;P&gt;ERROR [org.nuxeo.ecm.automation.core.events.OperationEventListener] Failed to handle event documentModified using chain: submitFOIAtoAgency
org.nuxeo.ecm.automation.OperationException: Failed to invoke operation Context.SetVar&lt;/P&gt;
&lt;P&gt;Caused by: [Error: could not access: Document; in class: null]
[Near : {... Unknown ....}]&lt;/P&gt;
&lt;P&gt;The value for the context setting is:&lt;/P&gt;
&lt;P&gt;@{Document["GOVAGENCY:agency_foia_poc_email"]} - which is a value in the document returned by the query (or at least it is supposed to)&lt;/P&gt;
&lt;P&gt;UPDATE:2/1/12&lt;/P&gt;
&lt;P&gt;I have everything figured out except for the Fetch returning null document.  If I run a query in Advanced Search it returns a document in the environment. If I take the &lt;STRONG&gt;same&lt;/STRONG&gt; NXQL query (with the hard coded parameters) and put it into the Fetch-&amp;gt;Query operation, it gives me the null document.&lt;/P&gt;
&lt;P&gt;Don&lt;/P&gt;</description>
    <pubDate>Fri, 27 Jan 2012 22:50:50 GMT</pubDate>
    <dc:creator>donbauer1_</dc:creator>
    <dc:date>2012-01-27T22:50:50Z</dc:date>
    <item>
      <title>Unable to Set Context variables..</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326423#M13424</link>
      <description>&lt;P&gt;I have an automation chain that&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;gets a value from a document,&lt;/LI&gt;
&lt;LI&gt;sets the context variable,&lt;/LI&gt;
&lt;LI&gt;pushes it onto the stack,&lt;/LI&gt;
&lt;LI&gt;uses nxql to query a document based on the context variable,&lt;/LI&gt;
&lt;LI&gt;sets another context variable with a value from the queried document,&lt;/LI&gt;
&lt;LI&gt;pops the previous document&lt;/LI&gt;
&lt;LI&gt;and then uses all of that to send an email template. (A classic lookup operation)..&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;When I hard code my "values" everything works as expected. When I attempt to set a context variable, it fails.&lt;/P&gt;
&lt;P&gt;The automation chain is as follows:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://connect.hyland.com/upfiles/contextproblemflow_1.jpg" alt="alt text" /&gt;&lt;/P&gt;
&lt;P&gt;Each time I attempt to get a value, it fails with the following entry in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;ERROR [org.nuxeo.ecm.automation.core.events.OperationEventListener] Failed to handle event documentModified using chain: submitFOIAtoAgency
org.nuxeo.ecm.automation.OperationException: Failed to invoke operation Context.SetVar
*and*
Caused by: [Error: org.nuxeo.ecm.core.api.impl.DocumentModelImpl cannot be cast to java.lang.Class]
[Near : {... Unknown ....}]
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The automation chain is being kicked off by a document Create or Edit event handler.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I have further refined my issue:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;during the Fetch-&amp;gt;Query operation I use the context variable as a parameter in my NXQL..&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I can run the query with the expected values and it returns a document&lt;/LI&gt;
&lt;LI&gt;I can run the query with a hard coded parameter and it doesn't fail.&lt;/LI&gt;
&lt;LI&gt;I can run the NXQL with SELECT * FROM Document WHERE GOVAGENCY:agency_id = '+@{Context["agencyid"]}+' and it gives no complaints or failures (I have HAD queries fail before)&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;The context variable setting fails due to null document (from the Fetch operation I presume)&lt;/P&gt;
&lt;P&gt;ERROR [org.nuxeo.ecm.automation.core.events.OperationEventListener] Failed to handle event documentModified using chain: submitFOIAtoAgency
org.nuxeo.ecm.automation.OperationException: Failed to invoke operation Context.SetVar&lt;/P&gt;
&lt;P&gt;Caused by: [Error: could not access: Document; in class: null]
[Near : {... Unknown ....}]&lt;/P&gt;
&lt;P&gt;The value for the context setting is:&lt;/P&gt;
&lt;P&gt;@{Document["GOVAGENCY:agency_foia_poc_email"]} - which is a value in the document returned by the query (or at least it is supposed to)&lt;/P&gt;
&lt;P&gt;UPDATE:2/1/12&lt;/P&gt;
&lt;P&gt;I have everything figured out except for the Fetch returning null document.  If I run a query in Advanced Search it returns a document in the environment. If I take the &lt;STRONG&gt;same&lt;/STRONG&gt; NXQL query (with the hard coded parameters) and put it into the Fetch-&amp;gt;Query operation, it gives me the null document.&lt;/P&gt;
&lt;P&gt;Don&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2012 22:50:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326423#M13424</guid>
      <dc:creator>donbauer1_</dc:creator>
      <dc:date>2012-01-27T22:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Set Context variables..</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326424#M13425</link>
      <description>&lt;P&gt;Can you give us the value you put into the operation set Context Variable, please ? You can put it directly into your question...&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2012 15:47:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326424#M13425</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-01-28T15:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Set Context variables..</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326425#M13426</link>
      <description>&lt;P&gt;Can you give us value set into your operations. And if your parameter refer to a specific field can you give the type you choose for this field and also the widget used into the creation/edit tab. I'm waiting something like&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2012 17:33:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326425#M13426</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-01-30T17:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Set Context variables..</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326426#M13427</link>
      <description>&lt;P&gt;Why do you have + in your request parameter '+@{Context["agencyid"]}+'?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2012 17:53:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326426#M13427</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-03-19T17:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to Set Context variables..</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326427#M13428</link>
      <description>&lt;P&gt;still open ?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Mar 2012 04:46:52 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/unable-to-set-context-variables/m-p/326427#M13428</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-03-30T04:46:52Z</dc:date>
    </item>
  </channel>
</rss>

