cancel
Showing results for 
Search instead for 
Did you mean: 

What is the name of the input variable which contains the documents for an operation?

Michael_Bell
Confirmed Champ
Confirmed Champ

I want to use the result from Document.GetChildren to calculate a dynamic folder name. My idea is that MVEL provide the length of an array via the object method size.

The problem is that I cannot find the right variable which contain the output documents. I know that an operation can return a list of documents or a reference to a list of documents. Nevertheless I don't find the correct variable name ;(

<?xml version="1.0"?>
  <component name="org.nuxeo.dev.cookbook.example.pap.process-request.chains">

    <extension target="org.nuxeo.ecm.core.operation.OperationServiceComponent" point="chains">

      <chain id="CreateDevCookbookExamplePapProcessRequest">
        <!--
          Input: Called from the folder with all requests
          Calculate a name for the new folder
          Create folder with title
          Create customer_form
          Open customer form
        -->
        <!-- get the folder as input -->
        <operation id="Seam.AddErrorMessage">
          <param type="string" name="message">Cannot load the folder with the requests.</param>
        </operation>
        <!-- usually unnecessary -->
        <operation id="Context.FetchDocument">
        </operation>
        <!-- determine number of children -->
        <operation id="Seam.AddErrorMessage">
          <param type="string" name="message">Cannot calculate the name of the new file.</param>
        </operation>
        <operation id="Context.SetInputAsVar">
          <param type="string" name="name">requests</param>
        </operation>
       <operation id="Document.GetChildren">
       </operation>
       <operation id="Context.SetVar">
         <param type="string" name="name">form_name</param>
         <!--
           here  I want to calculate a dynamic new file name
           BUT:  I cannot access the document list from GetChildren.
           BUT:  It looks like all variable names are unknown.
           MVEL: documents.size (should be the length of the list)
         -->
         <param type="object" name="value">expr:@{Documents.size}</param>
       </operation>

The error messages always look like this one:

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

The example is from the tutorial which I prepare for the Dev Cookbook.

1 ACCEPTED ANSWER

Laurent_Doguin
Star Collaborator
Star Collaborator

Hi Michael,

I manage to do it by first setting the input of the getChildren operation as a context variable. Here's a screenshot of my example:

View answer in original post

2 REPLIES 2

Laurent_Doguin
Star Collaborator
Star Collaborator

Hi Michael,

I manage to do it by first setting the input of the getChildren operation as a context variable. Here's a screenshot of my example:

Hi Laurent,