cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Set Context variables..

donbauer1_
Champ in-the-making
Champ in-the-making

I have an automation chain that

  • gets a value from a document,
  • sets the context variable,
  • pushes it onto the stack,
  • uses nxql to query a document based on the context variable,
  • sets another context variable with a value from the queried document,
  • pops the previous document
  • and then uses all of that to send an email template. (A classic lookup operation)..

When I hard code my "values" everything works as expected. When I attempt to set a context variable, it fails.

The automation chain is as follows:

alt text

Each time I attempt to get a value, it fails with the following entry in the log:

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 ....}]

The automation chain is being kicked off by a document Create or Edit event handler.

I have further refined my issue:

during the Fetch->Query operation I use the context variable as a parameter in my NXQL..

  1. I can run the query with the expected values and it returns a document
  2. I can run the query with a hard coded parameter and it doesn't fail.
  3. 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)

The context variable setting fails due to null document (from the Fetch operation I presume)

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

Caused by: [Error: could not access: Document; in class: null] [Near : {... Unknown ....}]

The value for the context setting is:

@{Document["GOVAGENCY:agency_foia_poc_email"]} - which is a value in the document returned by the query (or at least it is supposed to)

UPDATE:2/1/12

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 same NXQL query (with the hard coded parameters) and put it into the Fetch->Query operation, it gives me the null document.

Don

4 REPLIES 4

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

Can you give us the value you put into the operation set Context Variable, please ? You can put it directly into your question...

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

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

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

Why do you have + in your request parameter '+@{Context["agencyid"]}+'?

Benjamin_Jalon1
Elite Collaborator
Elite Collaborator

still open ?