cancel
Showing results for 
Search instead for 
Did you mean: 

How to get form fields values from share-config-custom.xml

croc
Champ in-the-making
Champ in-the-making
Hi,

I need to get fields from share-config-custom.xml.
Below is what did:

[b]File name: rmsearch.get.js[/b]
[b]Created a method called getFormFields()[/b]

function  getFormFields(){
var  scopedRoot = config.scoped["cm:content"]["forms"]["form"];
var configs = scopedRoot.getChildren("appearance");

………
}

share-config-custom.xml

   <!– cm:content type (existing nodes) –>
   <config  evaluator="node-type" condition="cm:content">
      <forms>
         <!– Default form configuration used on the document details and edit metadata pages –>
         <form>
            <field-visibility>
               <!– Indicators aspect–>
               <show id="simm:PAIA" />
               <show id="simm:Evidence" />
               <show id="simm:Config" />
               <show id="simm:AutoAssignReference" />
               <show id="simm:MRIPNB" />
            </field-visibility>
            <appearance>
               <field id="simm:PAIA" label-id="label.simm_PAIA" />
               <field id="simm:Evidence" label-id="label.simm_Evidence" />
               <field id="simm:Config" label-id="label.simm_Config" />
               <field id="simm:AutoAssignReference" label-id="label.simm_AutoAssignReference" />
               <field id="simm:MRIPNB" label-id="label.simm_MRIPNB" />
            </appearance>
         </form>
      </forms>
   </config>

And I get an error, "Cannot call method "getChildren""

Thanks,
Croc
3 REPLIES 3

gavinc
Champ in-the-making
Champ in-the-making
Hi,

Try using the following instead…

var  scopedRoot = config.scoped["cm:content"]["forms"].childrenMap["form"];
var configs = scopedRoot.getChildren("appearance");

gavinc
Champ in-the-making
Champ in-the-making
Apologies, the code I suggested above won't work either. The forms configuration uses specific ConfigElement implementations, not the generic ones (GenericConfigElement), therefore getChildren() and getChildrenMap() won't return anything.

I'm not sure from your example what information you are trying to retrieve, the code below will allow you to get a list of fields that will be editable in edit mode.

var scopedRoot = config.scoped["cm:content"];
var forms = scopedRoot["forms"];
var form = forms.defaultForm;
var visibleFields = form.visibleEditFieldNames;

The object you get back from scopedRoot["forms"] is org.alfresco.web.config.forms.FormsConfigElement you can have a look at it to see what methods are available to you, in the example above I have used getDefaultForm(). The object you then get back is org.alfresco.web.config.forms.FormConfigElement, this has quite a few methods you can call to get config information, in the example above i've used getVisibleEditFieldNames().

Hope this helps!

alhol
Champ in-the-making
Champ in-the-making
Thank you for such informative reply. Here is my situation: I have both "node-type" and "model-type" evaluator sections in my config, but
scopedRoot["forms"]
returns forms only for "model-type". I.e. if I have form with some id only in node-type section I cant get it. How can I do this?