Populate dialog with tag values | Community
Skip to main content
New Participant
March 18, 2016
Solved

Populate dialog with tag values

  • March 18, 2016
  • 3 replies
  • 2285 views

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.
Best answer by edubey

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

New Participant
June 13, 2017

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.

New Participant
March 19, 2016

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

edubey
edubeyAccepted solution
New Participant
March 19, 2016

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.