Expand my Community achievements bar.

SOLVED

Populate dialog with tag values

Avatar

Level 4

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 ?

1 Accepted Solution

Avatar

Correct answer by
Level 10

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.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

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.

Avatar

Level 4

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

Avatar

Level 2

Hi,

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

Plz find below the screen print:

1228612_pastedImage_0.png

1228625_pastedImage_1.png

1228626_pastedImage_2.png

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.