How to programmatically relate/unrelate an asset to another asset or content fragment? | Community
Skip to main content
New Participant
August 23, 2023
Solved

How to programmatically relate/unrelate an asset to another asset or content fragment?

  • August 23, 2023
  • 1 reply
  • 570 views

Hi,

 

Does someone have any sample code on how we can programmatically  relate/unrelate an asset to another asset or content fragment?

 

Basically looking for the highlighted OOB functionality that can be done programmatically instead of manual. I have a process to create QR code using Content fragment. So looking on options to relate them somehow, so that users can navigate to the right CF's which created it, by a link on it.

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Harwinder-singh

@p_v_nair I think the AssetRelation API should be the one that you are looking for. 

 

https://javadoc.io/static/com.adobe.aem/uber-jar/6.2.SP1-CFP15/com/adobe/granite/asset/api/Asset.html#addRelation-java.lang.String-java.lang.String-

You have an option to relate and unrelate assets using this one.

1 reply

Harwinder-singh
Harwinder-singhAccepted solution
New Participant
August 23, 2023

@p_v_nair I think the AssetRelation API should be the one that you are looking for. 

 

https://javadoc.io/static/com.adobe.aem/uber-jar/6.2.SP1-CFP15/com/adobe/granite/asset/api/Asset.html#addRelation-java.lang.String-java.lang.String-

You have an option to relate and unrelate assets using this one.