Populate dialog with tag values | Community
Skip to main content
Level 4
Mar 18, 2016 7:01 AM UTC
Solved

Populate dialog with tag values

Hello Team,

I want to get the tags(cq:tags) of the asset that I choose in the dialog. First, I have a textfield where I can select the required asset from DAM. Just below that, I want to show the tags associated to it in the dialog. Could you please help me with this ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
edubey
edubeyAccepted solution
Level 10
Mar 19, 2016 8:33 AM UTC

Hi,

 I have a textfield where I can select the required asset from DAM

I guess you are referring to pathfield not textfield. Now need to do this with listeners. below is the code you can use. It works for me

Make sure you have two field with 

1.Pathfield : where you will select path

2.Tag input field with name ./tags

Here is what dialogs looks like

Here is the output

Here is js Listener code you need to use

function(d) { path = this.value+"/jcr:content/metadata.json"; var x = CQ.shared.HTTP.eval(path); var tags = []; tags = x['cq:tags']; dialog = this.findParentByType('dialog'); field =  dialog.getField('./tags'); field.setValue(tags); }

Let me know if you face any issue.

3 replies

Level 2
Jun 13, 2017 7:40 AM UTC

Hi,

I have tried to the same thing in my component but its not working for me.

Plz find below the screen print:

so kindly suggest me what is the issue in my structure or what property i have missed.

and plz provide me the complete logic also.

Translate
Level 4
Mar 19, 2016 9:40 PM UTC

Many thanks Edubey. You saved a ton of my time.smiley

Translate
edubey
edubeyAccepted solution
Level 10
Mar 19, 2016 8:33 AM UTC

Hi,

 I have a textfield where I can select the required asset from DAM

I guess you are referring to pathfield not textfield. Now need to do this with listeners. below is the code you can use. It works for me

Make sure you have two field with 

1.Pathfield : where you will select path

2.Tag input field with name ./tags

Here is what dialogs looks like

Here is the output

Here is js Listener code you need to use

function(d) { path = this.value+"/jcr:content/metadata.json"; var x = CQ.shared.HTTP.eval(path); var tags = []; tags = x['cq:tags']; dialog = this.findParentByType('dialog'); field =  dialog.getField('./tags'); field.setValue(tags); }

Let me know if you face any issue.

Translate