Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Copying a component or experience fragement in AEM

Avatar

Level 8

When copying an Experience Fragement or a component in AEM, all of its conent is taken over. This is AEM basic functionality.

We would like to implement a solution that would not copy a specific Tab that all of our components have. This tab has values for Google Analytics and should be reset when copying.

 

Can you please suggest possible solutions on how to refactor the AEM copy/paste functionality that comes out of the box by resetting a specific Tab in all pasted paste_aem.PNGcomponents?

6 Replies

Avatar

Level 2

Option 1: Manually remove/update values after copying and pasting.

 

Option 2: Add a launcher which listens to specific node added events and resets the GTM property.  Remove launcher when the copy pasting is done.

 

Avatar

Level 8

Thanks @dasdfasfass 

Option 1 is clear.

Option 2 I am not sure how to implement. How do I set a listener for the out of the box copy/paste function?  What do you mean by "remove launcher"? How do I discern between nodes that are copied and nodes that are just created? I want to apply this workflow of mine only to copied nodes.

 

Could creating a "new" paste button that would reset the Tab values also be a viable option? 

Avatar

Community Advisor

Hi @anasustic ,

 

I can probably see 2 automatic approaches to this:

  1. Create a listener on this functionality. 
  2. Create a workflow launcher which will serve the same purpose.

Avatar

Level 8

Hi @Anmol_Bhardwaj 

Thanks for your answer.

Can you please point me to a reference describing how you envisioned to write a process step with the payload to delete the tab content using Java.

Best regards

Ana

Avatar

Community Advisor

This could be done SLING or JCR API.

https://venkatanagasudheer.blogspot.com/2019/09/delete-dam-asset-using-workflow_20.html

 

You can follow something similar to what's done here, instead of the whole node/asset, you can just delete the particular node. As the node position would be same when it is relative to the parent node. You can follow the same thing and delete just the DTM properties/node.

 

You can get a workflow item through:

WorkItem[] workItems = wfSession.getActiveWorkItems();