Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Ability to Remove Metadata Values from Multiple Assets at Once

Avatar

Level 1

1/31/22

Request for Feature Enhancement (RFE) Summary: Allow users the ability to remove metadata values from multiple assets when selected via multselect
Use-case:

We can select multiple assets today and then click Properties, to add metadata to all those assets.  DAM librarians are wanting to do the same steps, but to Remove certain pieces of metadata. For example, if we needed to remove a Tag field we originally selected on a set of assets, we’d have to access each asset, one at a time, to do that.   This is especially difficult when the selection was just user error, and now hundreds of assets must be selected, one at a time, to remove that selection.

Current/Experienced Behavior: Not able to remove metadata from multiple assets at once
Improved/Expected Behavior: Add the ability to remove metadata values from assets, when multiple assets are selected at once.
Environment Details (AEM version/service pack, any other specifics if applicable): 6.5.9+
Customer-name/Organization name: Humana
Screenshot (if applicable):  
Code package (if applicable):  
1 Comment

Avatar

Employee Advisor

2/1/22

I feel using workflow we could allow content authors or business to remove metadata values from multiple assets when selected via multiselect.

 

Here is the sample workflow process step for the same -

package com.aem.demo.core.workflows;

import java.util.Objects;

import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;

@component(property = {
Constants.SERVICE_DESCRIPTION + "=This workflow process step is responsible to remove bulk asset metadata",
Constants.SERVICE_VENDOR + "=AEM Demo Debal", "process.label" + "= Bulk Asset Metadata" })
public class RemoveBulkAssetMetadata implements WorkflowProcess {

private final Logger logger = LoggerFactory.getLogger(RemoveBulkAssetMetadata.class);

@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)
throws WorkflowException {
try {

ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);

String payLoadPath = workItem.getWorkflowData().getPayload().toString();

logger.info("*** Payload Path ***{}", payLoadPath);

Resource resource = resourceResolver.getResource(payLoadPath);

if (Objects.nonNull(resource) && resource.isResourceType("dam:Asset")) {

logger.info("*** Payload Name ***{}", resource.getName());

Resource metadataResourec = resource.getChild("jcr:content/metadata");
ModifiableValueMap modifiableValueMap = metadataResourec.adaptTo(ModifiableValueMap.class);
if (modifiableValueMap.containsKey("cq:tags")) {

logger.info("*** Inside Metadata*** ");
modifiableValueMap.remove("cq:tags");
}

resourceResolver.commit();

}
} catch (PersistenceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

 

Sample workflow medel -

 

DEBAL_DAS_0-1643724402688.png

Process step detail-

DEBAL_DAS_1-1643724430527.png

 

I have tested on multiple assets  via multiselect approach and I am also using AEM 6.5.9. Please talk your content authors or business will they comfortable to use AEM workflow for this use case.