Expand my Community achievements bar.

AEM Metadata Schema Dynamic Dropdown

Avatar

Level 4

I have a dropdown field in the metadata schema editor and I want the options of this dropdown to be populated dynamically from a servlet response. I am following below guide to achieve it. There is a question around my requirement and from the author's answer it seems just pointing the JSON path to the servlet should help achieve it. Has anybody come across this before? Do you know if it works coz I have not been able to achieve it. If i point the JSON path to an nt:file it works.

Using a JSON file with the Dropdown widget on the Metadata Schema | Content Management

Options array from the servlet or in the JSON file

{

"options": [

{

"value": "en-gb",

"text": "English-United Kingdom"

},

{

"value": "en-us",

"text": "English-United States"

},

{

"value": "fr-ca",

"text": "French-Canada"

},

{

"value": "fr-fr",

"text": "French-France"

},

{

"value": "de-de",

"text": "German-Germany"

},

{

"value": "es-mx",

"text": "Spanish-Mexico"

},

{

"value": "es-es",

"text": "Spanish-Spain"

}

]

}

JSON path value - /etc/tags/custom/industries.options.json

4 Replies

Avatar

Level 10

You can populate a GRANITE Select with a Sling Servlet. Is this dropdown a Granite Select field?

Avatar

Level 1

Not sure if this is what you're talking about but it could be in a Show/Hide that's in the standard library. Here's a video on this FWIW.

D

Avatar

Level 2

Hi, I am replying on an old thread. But I had the similar problem and not found any solution so tried some custom approach and able to achieve this.

Solution:

1. overlay/customise default  metadataschema using metadataschema editor.(http://www.sgaemsolutions.com/2017/02/overrideoverlay-dam-asset-metadata-in.html )

2. Add custom dropdown field using datasource object to populate dropdown.

https://helpx.adobe.com/experience-manager/using/aem65_coral_resourcetypes.html#UseaDataSourceObject... 

 

For Example: I have added below dropdown in my metadataschema dialog xml to dynamically populate dropdown from my servlet

 <_x0031_612365521559
                                        jcr:primaryType="nt:unstructured"
                                        sling:resourceType="dam/gui/components/admin/schemafield"
                                        emptyText="Select Option"
                                        fieldLabel="Collections"
                                        name="./jcr:content/metadata/test"
                                        resourceType="granite/ui/components/coral/foundation/form/select">
                                    <granite:data
                                            jcr:primaryType="nt:unstructured"
                                            choicesCascading="default"
                                            cq-msm-lockable="./metadata/test"
                                            metaType="dropdown"
                                            requiredCascading="default"
                                            visibilityCascading="default"/>
                                    <datasource
                                            jcr:primaryType="nt:unstructured"
                                            sling:resourceType="<servlet resourceType>"
                                            addNone="{Boolean}true"/>
                                    <cascadeitems
                                            jcr:primaryType="nt:unstructured"
                                            sling:resourceType="dam/gui/coral/components/admin/schemaforms/formbuilder/cascadeitems"/>
                                </_x0031_612365521559>