Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

How to populate a list in select dropdown field where the list of values depends on the ID which is configured in another text field?

Avatar

Level 4

There's a dialog field that consists of a text field where we have to enter an ID. There's a select dropdown field which renders the values from the API which required the  ID as a parameter. 

Is there a way to populate the dropdown list dynamically when the ID is authored , on field change, without submitting the dialog twice?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
5 Replies

Avatar

Level 4

Should I write an ajax in the listner js and trigger the servlet?

Avatar

Correct answer by
Community Advisor

I think this fits your use case. Let me know if you any questions.

https://aemlab.blogspot.com/2022/01/aemaacs-touch-ui-dialog-dynamic-dropdown.html

Avatar

Level 4

Hi @JeevanRaj ,

 

Thank you for your help. It's working as expected even when the input is a text field.

 

Avatar

Level 6

Hi @chinmayis865517 

 

Instead of entering an ID in the text field which requires to submit dialog to save content in jcr, unless written some custom script to listen the text field values, i would suggest to go with selection of values from first dropdown which dynamically populates the values in the second dropdown

 

Here are few examples to check -

https://kiransg.com/tag/datasource/

https://adapttoaem.blogspot.com/2021/02/setting-dynamic-dropdownselect-value-in.html

 

Hope this helps

 

Thanks

Avatar

Level 4

Hi @PRATHYUSHA_VP ,

 

We are using text field because if the select dropdown field is used, the list is very long and may cross 100 items.

The solution worked with the first field as text. Thank you for your help.