Expand my Community achievements bar.

SOLVED

Bulk adding cq:tags to DAM assets

Avatar

Level 4

Hi All,

I have about 10k DAM assets that all require me to add a set of cq:tags to them. 

I have tried exporting the dam metadata adding the tags to the .csv and reimporting that (Column 'cq:tags' - Tags 'example:AU/NSW')

Once I import it and check on an assets properties I do not see the tag in the tags field. However, if I export the metadata again after doing the above I can see in the cq:tags column the tags I imported.. which is a tad confusing.

Any ideas what I might be missing here? 

Kindest Regards,

1 Accepted Solution

Avatar

Correct answer by
Level 4

Ah I have found out why it was behaving badly...

When I export the metadata from the DAM its calls the column cq:tags{{String}} when it should be cq:tags{{String: multi }} and it separates tags with ; when it should be using |

Making these changes to my .csv file has resulted in the tags now appearing on my assets haha. so strange.

View solution in original post

10 Replies

Avatar

Level 5

Hi @RooRue 

 

Are these tags present in you system under '/content/cq:tags'?

To be visible in tag field saved property must be resolved as a valid tag.

Avatar

Employee

Hi @RooRue  ,

Could you please check the below points?

->When you are importing metadata make sure you are using the correct settings, and mapping in the column, Also ensure you are importing CSV files in the appropriate location and check for the import assets permission is correct.

->The 'cq:tags' property in AEM is a multivalued property, meaning it can hold multiple tag values,make it sure the setting of cq:tags property as a list of tags in the CSV file.

->Verify that the 'example' namespace used in the CSV matches the actual namespace defined in AEM for the tags

Avatar

Level 4

Hi @Ekhlaque 

In this same spreadsheet if i adjust the dc:title it does actually apply that to the asset properties.

The tags i am trying to add are from this path - /content/cq:tags/example/CV/JGS
this is the column in my .csv that im trying to import.

RooRue_0-1690350623977.png

 

Avatar

Employee

Can you please share the headings and some values of your csv file?

there might be 2 reasons.

1. the tags that you added in ca:tags property does not exist under /content/cq:tags 

2. Check the property type if you are using Multi values.

  • Multi Value Property format - <metadata property name> {{<property type : MULTI }}

 

Avatar

Level 4

Hi Nishant-Singh,

Here is the tags column in my .csv and also a snippet for how the tags look in devs crxde - 

RooRue_0-1690333200593.pngRooRue_1-1690333206719.png

 

Avatar

Community Advisor

Hi @RooRue,

I have done bulk tagging for pages. You will get an idea from this.

 

Resource contentResource = page.getContentResource();
Node contentNode = contentResource.adaptTo(Node.class);

if (contentNode != null) {
    ValueFactory valueFactory = session.getValueFactory();
    if (contentNode.hasProperty(PAGE_TAG)) {
        Property pageTagProperty = contentNode.getProperty(PAGE_TAG);
        Value[] existingValues = pageTagProperty.getValues();
        List<Value> updatedValues = new ArrayList<>(Arrays.asList(existingValues));
        updatedValues.add(0, valueFactory.createValue(tag.getTagID()));
        pageTagProperty.setValue(updatedValues.toArray(new Value[0]));
    } else {
        List<Value> updatedValues = new ArrayList<>();
        updatedValues.add(valueFactory.createValue(tag.getTagID()));
        contentNode.setProperty(PAGE_TAG, updatedValues.toArray(new Value[0]));
    }
    resourceResolver.commit();
}

 

 In asset, we have cq:tags under metadata. So you need to update this property.

Make sure the property is multivalued.

AsifChowdhury_0-1690270704084.png

adapt that resource to the Node class and set the property by updating Value.

NB: This code snippet is for updating the tags for pages.

Avatar

Community Advisor

Hello @RooRue 

 

It might be a data issue.

 

Validating Tag ID:

For one of the assets, where the tag is set, but not visible, try adding an existing tag again (one that was added via Excel also).

  • See, if it the populates on re-opening the property link.
  • If yes, please visit the Asset via CRXDE. Cross-check the tags property. Is there any difference in:
    • What was set via Excel?
    • From properties screen?

 

Validating access to Tags

  • Please validate that you have read access to the tags

 


Aanchal Sikka

Avatar

Level 4

Hi Aanchal-Sikka,

I have taken one of the documents I was testing (the one that I tried importing tags into) and manually added a tag via the properties. When I close and open that tag is still visible and is the only tage visible on that document in CRXDE.

When I got back to the documents folder and grab a new metadata export and add tags to it again it removes even the tag I had manually put there. Infact it's removing all the tags from all the documents in that folder. (Edit - Although the tags still show in the metadata export.. Just not on the documents properties page)

Avatar

Correct answer by
Level 4

Ah I have found out why it was behaving badly...

When I export the metadata from the DAM its calls the column cq:tags{{String}} when it should be cq:tags{{String: multi }} and it separates tags with ; when it should be using |

Making these changes to my .csv file has resulted in the tags now appearing on my assets haha. so strange.