cancel
Showing results for 
Search instead for 
Did you mean: 

Dinamic select in form template control

pablog_
Champ in-the-making
Champ in-the-making
Hi, Is it possible to do next?

I have a pool of documents in a folder; When I start a workflow, I need an input of type "select" that shows all the documents name in that folder:

The form in the share-config-custom.xml is:


<config evaluator="string-compare" condition="activiti$miForm">
   <forms>
         <form>
            <field-visibility>
               <show id="bgwf:myPropertie1" />
            </field-visibility>
            <appearance>
               <set id="mySet" apprearance="title" label-id="workflow.set.Info"/>
            <field id="bgwf:startSAPAction" label-id="workflow.field.opSAPAction" set="mySet" >
           <control template="/org/alfresco/components/form/controls/workflow/my-custom-control.ftl" />
            </field>
            </appearance>
         </form>
      </forms>
</config>


And the file my-custom-control.ftl" contains:


<div class="form-field">   
     <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
     <select id="${fieldHtmlId}" name="${field.name}" tabindex="0">
       <#list companyhome.childrenByLuceneSearch["PATH:\"/app:company_home/cm:Folder_test/*\""] as child>
      <option value="${child.properties["name"]}">${child.properties["name"]}</option>
       </#list>
     </select>
</div>


But when I going to start the workflow, the next exception is through:


2013-11-27 12:59:18,094  ERROR [freemarker.runtime] [http-apr-28080-exec-6] Template processing error: "Expression companyhome is undefined on line 11, column 40 in org/alfresco/components/form/controls/workflow/my-custom-control.ftl."

Expression companyhome is undefined on line 11, column 40 in org/alfresco/components/form/controls/workflow/my-custom-control.ftl.


If companyhome is an root object and I can use this code in a WebScript, why can't use this way in the control template?

Thank you for your help!
2 REPLIES 2

parzgnat
Star Contributor
Star Contributor
Root objects are not accessible from FTL, only items placed into the model root object are.  Root objects are accessible from server-side JavaScript.

See http://docs.alfresco.com/4.0/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Freferences%2FAPI-JS-ro...

pablog_
Champ in-the-making
Champ in-the-making
Thanks Parzgnat, then, how can I get the document list to render the "select" field in the form?

And other question, Why can I use the "companyhome" variable in a webScript, for example test.get.html.flt.

Thank you!