Expand my Community achievements bar.

SOLVED

Is there a way to get all information submitted for a specific metadata field for all assets?

Avatar

Level 1

For example, if there is an asset description field in the form for asset upload, would there be a way to combine and show all entered asset descriptions easily?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@CodeRrave818 If you have Groovy console installed, you can try below script to fetch desired records - 

import com.day.cq.dam.api.Asset
import com.day.cq.dam.api.AssetManager

def damPath = "/content/dam/demo"

def assetManager = sling.getService(AssetManager.class)
def folder = assetManager.getAsset(damPath)

folder.listChildren().each { Asset asset ->
    def description = asset.getMetadataValue("dc:description")
    log.info("Asset Name: ${asset.getName()}, Description: ${description}")
}

View solution in original post

4 Replies

Avatar

Community Advisor

@CodeRrave818 You can query the assets using query builder API and get all the asset's and its description

 

type=dam:Asset

path=<PATH to you assets folder>

p.properties=jcr:content/metadata/jcr:description jcr:path

p.limit=-1

Avatar

Level 4

I think the Export Metadata function would be the best way to capture all the entered asset descriptions.  If you did this at the top-level of your /content/dam folder tree, you would get all the entries for selected metadata field(s) for the entire repository into a CSV. 

 

One tip to mention: in addition to the relevant field you're analyzing, you should also include some metadata field that is automatically completed by the system for all assets in the repository.  If you don't do so, assets without a value in the field will not export.

 

For unstructured data like description, it seems like it would be hard to do much with that information in a large repository.  Unless you have very good governance to dictate that some structured property (i.e. product SKU) is entered in the description metadata, it seems as if you'd have a long list of text strings in your CSV.  You might be able to run some analysis on this--i.e. what percentage of assets has this field completed.  But I'm not sure what else you could do with this information across a large repository of assets.

 

Hope this helps! 

Avatar

Level 1

@Saravanan_Dharmaraj , @FreedomMarketin Thank you both for your help. Both of these were helpful, but I couldn't get either to work in my favor. Not exactly sure what I'm missing, but I will try again to see if I can get it working.

Avatar

Correct answer by
Community Advisor

@CodeRrave818 If you have Groovy console installed, you can try below script to fetch desired records - 

import com.day.cq.dam.api.Asset
import com.day.cq.dam.api.AssetManager

def damPath = "/content/dam/demo"

def assetManager = sling.getService(AssetManager.class)
def folder = assetManager.getAsset(damPath)

folder.listChildren().each { Asset asset ->
    def description = asset.getMetadataValue("dc:description")
    log.info("Asset Name: ${asset.getName()}, Description: ${description}")
}