Copying a component or experience fragement in AEM | Community
Skip to main content
Level 6
June 10, 2022

Copying a component or experience fragement in AEM

  • June 10, 2022
  • 2 replies
  • 2143 views

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 components?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Level 1
June 10, 2022

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.

 

anasusticAuthor
Level 6
June 13, 2022

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? 

Anmol_Bhardwaj
Community Advisor
Community Advisor
June 14, 2022

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.
anasusticAuthor
Level 6
June 15, 2022

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

Anmol_Bhardwaj
Community Advisor
Community Advisor
June 15, 2022

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();